예제 #1
0
        TDestination IMapper.Map <TSource, TDestination>(TSource source, TDestination destination)
        {
            var types = TypePair.Create(source, destination, typeof(TSource), typeof(TDestination));

            var func = _configurationProvider.GetMapperFunc <TSource, TDestination>(types);

            return(func(source, destination, _defaultContext));
        }
예제 #2
0
        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);

            typedOptions.BeforeMapAction(source, destination);

            var context = new ResolutionContext(typedOptions, this);

            destination = func(source, destination, context);

            typedOptions.AfterMapAction(source, destination);

            return(destination);
        }