public TDestination Map <TSource, TDestination>(TSource source, Action <IMappingOperationOptions <TSource, TDestination> > opts) { var types = TypePair.Create(source, typeof(TSource), typeof(TDestination)); var key = new TypePair(typeof(TSource), typeof(TDestination)); var typedOptions = new MappingOperationOptions <TSource, TDestination>(ServiceCtor); opts(typedOptions); var mapRequest = new MapRequest(key, types, typedOptions.InlineConfiguration); var func = ConfigurationProvider.GetMapperFunc <TSource, TDestination>(mapRequest); var destination = default(TDestination); typedOptions.BeforeMapAction(source, destination); var context = new ResolutionContext(typedOptions, this); destination = func(source, destination, context); typedOptions.AfterMapAction(source, destination); return(destination); }
public ResolutionContext(object source, object destination, TypePair types, MappingOperationOptions options, IRuntimeMapper mapper) { SourceValue = source; DestinationValue = destination; Options = options; Mapper = mapper; Types = types; }
private object MapCore(object source, Type sourceType, Type destinationType, MappingOperationOptions options) { TypeMap typeMap = ConfigurationProvider.ResolveTypeMap(source, null, sourceType, destinationType); var context = new ResolutionContext(typeMap, source, sourceType, destinationType, options, this); return(((IMappingEngineRunner)this).Map(context)); }
public ResolutionContext(TypeMap typeMap, object source, object destination, Type sourceType, Type destinationType, MappingOperationOptions options, IMappingEngine engine) : this(Empty, source, destination, sourceType, destinationType, typeMap) { InstanceCache = new Dictionary <ResolutionContext, object>(); Options = options; Engine = engine; }
public object Map(object source, Type sourceType, Type destinationType, Action <IMappingOperationOptions> opts) { var options = new MappingOperationOptions(); opts(options); return(MapCore(source, sourceType, destinationType, options)); }
private object MapCore(object source, object destination, Type sourceType, Type destinationType, MappingOperationOptions options) { TypeMap typeMap = _configurationProvider.ResolveTypeMap(source, destination, sourceType, destinationType); var context = new ResolutionContext(typeMap, source, destination, sourceType, destinationType, options, _engine); return(_engine.Map(context)); }
public ResolutionContext(TypeMap typeMap, object source, object destination, Type sourceType, Type destinationType, MappingOperationOptions options) { TypeMap = typeMap; SourceValue = source; DestinationValue = destination; AssignTypes(typeMap, sourceType, destinationType); InstanceCache = new Dictionary <ResolutionContext, object>(); Options = options; }
public TDestination Map <TSource, TDestination>(TSource source, Action <IMappingOperationOptions <TSource, TDestination> > opts) { Type modelType = typeof(TSource); Type destinationType = typeof(TDestination); var options = new MappingOperationOptions <TSource, TDestination>(); opts(options); return((TDestination)MapCore(source, modelType, destinationType, options)); }
private TDestination MapWithOptions <TSource, TDestination>(TSource source, TDestination destination, Action <IMappingOperationOptions <TSource, TDestination> > opts, Type sourceType = null, Type destinationType = null) { var typedOptions = new MappingOperationOptions <TSource, TDestination>(DefaultContext.Options.ServiceCtor); opts(typedOptions); typedOptions.BeforeMapAction?.Invoke(source, destination); destination = MapCore(source, destination, new ResolutionContext(typedOptions, this), sourceType, destinationType); typedOptions.AfterMapAction?.Invoke(source, destination); return(destination); }
public object Map(object source, object destination, Type sourceType, Type destinationType, Action <IMappingOperationOptions> opts) { TypeMap typeMap = ConfigurationProvider.FindTypeMapFor(source, sourceType, destinationType); var options = new MappingOperationOptions(); opts(options); var context = new ResolutionContext(typeMap, source, destination, sourceType, destinationType, options); return(((IMappingEngineRunner)this).Map(context)); }
TDestination IMapper.Map <TSource, TDestination>(TSource source, TDestination destination, Action <IMappingOperationOptions <TSource, TDestination> > opts) { var typedOptions = new MappingOperationOptions <TSource, TDestination>(_inner.ServiceCtor); opts(typedOptions); typedOptions.BeforeMapAction(source, destination); destination = _inner.Map(source, destination, this); typedOptions.AfterMapAction(source, destination); return(destination); }
TDestination IMapper.Map <TSource, TDestination>(TSource source, TDestination destination, Action <IMappingOperationOptions <TSource, TDestination> > opts) { var types = TypePair.Create(source, destination, typeof(TSource), typeof(TDestination)); var func = _configurationProvider.GetMapperFunc <TSource, TDestination>(types); var typedOptions = new MappingOperationOptions <TSource, TDestination>(_serviceCtor); opts(typedOptions); var context = new ResolutionContext(source, destination, types, typedOptions, this); return(func(source, destination, context)); }
object IMapper.Map(object source, Type sourceType, Type destinationType, Action <IMappingOperationOptions> opts) { var types = TypePair.Create(source, null, sourceType, destinationType); var func = _configurationProvider.GetUntypedMapperFunc(new MapRequest(new TypePair(sourceType, destinationType), types)); var options = new MappingOperationOptions(_serviceCtor); opts(options); var context = new ResolutionContext(source, null, types, options, this); return(func(source, null, context)); }
public ResolutionContext(TypeMap typeMap, object source, object destination, Type sourceType, Type destinationType, MappingOperationOptions options, IMappingEngine engine) { TypeMap = typeMap; SourceValue = source; DestinationValue = destination; if (typeMap != null) { SourceType = typeMap.SourceType; DestinationType = typeMap.DestinationType; } else { SourceType = sourceType; DestinationType = destinationType; } InstanceCache = new Dictionary <ResolutionContext, object>(); Options = options; Engine = engine; }
TDestination IMapper.Map <TSource, TDestination>(TSource source, Action <IMappingOperationOptions <TSource, TDestination> > opts) { var types = TypePair.Create(source, null, typeof(TSource), typeof(TDestination)); var func = _configurationProvider.GetMapperFunc <TSource, TDestination>(types); var destination = default(TDestination); var typedOptions = new MappingOperationOptions <TSource, TDestination>(_serviceCtor); opts(typedOptions); typedOptions.BeforeMapAction(source, destination); var context = new ResolutionContext(typedOptions, this); destination = func(source, destination, context); typedOptions.AfterMapAction(source, destination); return(destination); }
public ResolutionContext(TypeMap typeMap, object source, Type sourceType, Type destinationType, MappingOperationOptions options) : this(typeMap, source, null, sourceType, destinationType, options) { }
public ResolutionContext(MappingOperationOptions options, IRuntimeMapper mapper) { Options = options; Mapper = mapper; }
public Mapper(IConfigurationProvider configurationProvider, Func <Type, object> serviceCtor) { _configurationProvider = configurationProvider; _serviceCtor = serviceCtor; _defaultMappingOptions = new MappingOperationOptions(_serviceCtor); }