public TDestination Map <TSource, TDestination>(ResolutionContext parentContext, TSource source) { Type destinationType = typeof(TDestination); Type sourceType = typeof(TSource); TypeMap typeMap = ConfigurationProvider.FindTypeMapFor(source, sourceType, destinationType); var context = parentContext.CreateTypeContext(typeMap, source, sourceType, destinationType); return((TDestination)((IMappingEngineRunner)this).Map(context)); }
public object ResolveValue(ResolutionContext context, IMappingEngineRunner mappingEngine) { var ctorArgs = new List <object>(); foreach (var map in CtorParams) { var result = map.ResolveValue(context); var sourceType = result.Type; var destinationType = map.Parameter.ParameterType; var typeMap = mappingEngine.ConfigurationProvider.FindTypeMapFor(result, destinationType); Type targetSourceType = typeMap != null ? typeMap.SourceType : sourceType; var newContext = context.CreateTypeContext(typeMap, result.Value, targetSourceType, destinationType); var value = mappingEngine.Map(newContext); ctorArgs.Add(value); } return(_runtimeCtor(ctorArgs.ToArray())); }