void IProfileConfiguration.Register(TypeMapRegistry typeMapRegistry) { Prefixes = MemberConfigurations .Select(m => m.NameMapper) .SelectMany(m => m.NamedMappers) .OfType <PrePostfixName>() .SelectMany(m => m.Prefixes) .ToArray(); Postfixes = MemberConfigurations .Select(m => m.NameMapper) .SelectMany(m => m.NamedMappers) .OfType <PrePostfixName>() .SelectMany(m => m.Postfixes) .ToArray(); foreach (var config in _typeMapConfigs.Where(c => !c.IsOpenGeneric)) { BuildTypeMap(typeMapRegistry, config); if (config.ReverseTypeMap != null) { BuildTypeMap(typeMapRegistry, config.ReverseTypeMap); } } }
public IMappingExpression ReverseMap() { var reverseMap = new MappingExpression(new TypePair(Types.DestinationType, Types.SourceType), MemberList.Source); reverseMap.MemberConfigurations.AddRange(MemberConfigurations.Select(m => m.Reverse()).Where(m => m != null)); ReverseMapExpression = reverseMap; return(reverseMap); }
public IMappingExpression ReverseMap() { var reversedTypes = new TypePair(Types.DestinationType, Types.SourceType); var reverseMap = new MappingExpression(reversedTypes, MemberList.None); if (!reversedTypes.IsGenericTypeDefinition) { reverseMap.MemberConfigurations.AddRange(MemberConfigurations.Select(m => m.Reverse()).Where(m => m != null)); } ReverseMapExpression = reverseMap; reverseMap.IncludeMembers(MapToSourceMembers().Select(m => m.DestinationMember.Name).ToArray()); foreach (var includedMemberName in IncludedMembersNames) { reverseMap.ForMember(includedMemberName, m => m.MapFrom(s => s)); } return(reverseMap); }