本文整理汇总了C#中AutoMapper.TypeMap.AddPropertyMap方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMap.AddPropertyMap方法的具体用法?C# TypeMap.AddPropertyMap怎么用?C# TypeMap.AddPropertyMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoMapper.TypeMap
的用法示例。
在下文中一共展示了TypeMap.AddPropertyMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeMap
public TypeMap CreateTypeMap(Type sourceType, Type destinationType, IMappingOptions options, MemberList memberList)
{
var sourceTypeInfo = GetTypeInfo(sourceType);
var destTypeInfo = GetTypeInfo(destinationType);
var typeMap = new TypeMap(sourceTypeInfo, destTypeInfo, memberList);
foreach (var destProperty in destTypeInfo.GetPublicWriteAccessors())
{
var members = new LinkedList<MemberInfo>();
if (MapDestinationPropertyToSource(members, sourceTypeInfo, destProperty.Name, options))
{
var resolvers = members.Select(mi => mi.ToMemberGetter());
var destPropertyAccessor = destProperty.ToMemberAccessor();
#if !SILVERLIGHT
typeMap.AddPropertyMap(destPropertyAccessor, resolvers);
#else
typeMap.AddPropertyMap(destPropertyAccessor, resolvers.Cast<IValueResolver>());
#endif
}
}
if (!destinationType.IsAbstract && destinationType.IsClass)
{
foreach (var destCtor in destTypeInfo.GetConstructors().OrderByDescending(ci => ci.GetParameters().Length))
{
if (MapDestinationCtorToSource(typeMap, destCtor, sourceTypeInfo, options))
{
break;
}
}
}
return typeMap;
}
示例2: CreateTypeMap
public TypeMap CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options, MemberList memberList)
{
var sourceTypeInfo = options.CreateTypeDetails(sourceType);
var destTypeInfo = options.CreateTypeDetails(destinationType);
var typeMap = new TypeMap(sourceTypeInfo, destTypeInfo, memberList, options);
foreach (var destProperty in destTypeInfo.PublicWriteAccessors)
{
var resolvers = new LinkedList<MemberInfo>();
if (MapDestinationPropertyToSource(options, sourceTypeInfo, destProperty.DeclaringType, destProperty.GetMemberType(), destProperty.Name, resolvers))
{
typeMap.AddPropertyMap(destProperty, resolvers);
}
}
if (!destinationType.IsAbstract() && destinationType.IsClass())
{
foreach (var destCtor in destTypeInfo.Constructors.OrderByDescending(ci => ci.GetParameters().Length))
{
if (MapDestinationCtorToSource(typeMap, destCtor, sourceTypeInfo, options))
{
break;
}
}
}
return typeMap;
}
示例3: CreateTypeMap
public TypeMap CreateTypeMap(Type sourceType, Type destinationType, IProfileConfiguration options, MemberList memberList)
{
var sourceTypeInfo = GetTypeInfo(sourceType, options);
var destTypeInfo = GetTypeInfo(destinationType, options);
var typeMap = new TypeMap(sourceTypeInfo, destTypeInfo, memberList, options.ProfileName);
foreach (var destProperty in destTypeInfo.PublicWriteAccessors)
{
var resolvers = new LinkedList<IValueResolver>();
if (MapDestinationPropertyToSource(options, sourceTypeInfo, destProperty.GetMemberType(), destProperty.Name, resolvers))
{
var destPropertyAccessor = destProperty.ToMemberAccessor();
typeMap.AddPropertyMap(destPropertyAccessor, resolvers);
}
}
if (!destinationType.IsAbstract() && destinationType.IsClass())
{
foreach (var destCtor in destTypeInfo.Constructors.OrderByDescending(ci => ci.GetParameters().Length))
{
if (MapDestinationCtorToSource(typeMap, destCtor, sourceTypeInfo, options))
{
break;
}
}
}
return typeMap;
}
示例4: CreateTypeMap
public TypeMap CreateTypeMap(Type sourceType, Type destinationType, IMappingOptions options)
{
var sourceTypeInfo = GetTypeInfo(sourceType);
var destTypeInfo = GetTypeInfo(destinationType);
var typeMap = new TypeMap(sourceTypeInfo, destTypeInfo);
foreach (var destProperty in destTypeInfo.GetPublicWriteAccessors())
{
var members = new LinkedList<MemberInfo>();
if (MapDestinationPropertyToSource(members, sourceTypeInfo, destProperty.Name, options))
{
var resolvers = members.Select(mi => mi.ToMemberGetter()).Cast<IValueResolver>();
var destPropertyAccessor = destProperty.ToMemberAccessor();
typeMap.AddPropertyMap(destPropertyAccessor, resolvers);
}
}
return typeMap;
}