示例#1
0
 internal void DecrementTypeDepth(TypePair types)
 {
     TypeDepth[types]--;
 }
示例#2
0
 internal void IncrementTypeDepth(TypePair types)
 {
     TypeDepth[types]++;
 }
示例#3
0
 public bool IsConventionMap(TypePair types) => TypeConfigurations.Any(c => c.IsMatch(types));
示例#4
0
        public TypeMap CreateClosedGenericTypeMap(ITypeMapConfiguration openMapConfig, TypePair closedTypes, IConfigurationProvider configurationProvider)
        {
            var closedMap = _typeMapFactory.CreateTypeMap(closedTypes.SourceType, closedTypes.DestinationType, this);

            closedMap.IsClosedGeneric = true;
            openMapConfig.Configure(closedMap);

            Configure(closedMap, configurationProvider);

            if (closedMap.TypeConverterType != null)
            {
                var typeParams =
                    (openMapConfig.SourceType.IsGenericTypeDefinition() ? closedTypes.SourceType.GetGenericArguments() : new Type[0])
                    .Concat
                        (openMapConfig.DestinationType.IsGenericTypeDefinition() ? closedTypes.DestinationType.GetGenericArguments() : new Type[0]);

                var neededParameters = closedMap.TypeConverterType.GetGenericParameters().Length;
                closedMap.TypeConverterType = closedMap.TypeConverterType.MakeGenericType(typeParams.Take(neededParameters).ToArray());
            }
            if (closedMap.DestinationTypeOverride?.IsGenericTypeDefinition() == true)
            {
                var neededParameters = closedMap.DestinationTypeOverride.GetGenericParameters().Length;
                closedMap.DestinationTypeOverride = closedMap.DestinationTypeOverride.MakeGenericType(closedTypes.DestinationType.GetGenericArguments().Take(neededParameters).ToArray());
            }
            return(closedMap);
        }
示例#5
0
 public MapRequest(TypePair requestedTypes, TypePair runtimeTypes, IMemberMap memberMap = null)
     : this(requestedTypes, runtimeTypes, new MapperConfiguration.DefaultTypeMapConfig(requestedTypes), memberMap)
 {
 }