Exemplo n.º 1
0
        // Typed Submit Raw Auto
        public IAutoMapperRequestKey <TSource, TDestination> SubmitRawAutoMapperRequest <TSource, TDestination>
        (
            IMapTypeDefinition srcMapTypeDef,
            IMapTypeDefinition dstMapTypeDef,
            IAutoMapperConfigDetails configuationDetails,
            IConfigureAMapper <TSource, TDestination> mappingConfiguration,
            IHaveAMapperConfigurationStep configStarterForThisRequest
        )
        {
            // Create a MapperBuilder for this request.
            IAutoMapperBuilder <TSource, TDestination> autoMapperBuilder
                = BuildTheAutoMapperBuilder <TSource, TDestination>(configStarterForThisRequest);

            // Create the mapper request.
            IAutoMapperRequestKey <TSource, TDestination> autoMapperRequestKey
                = new AutoMapperRequestKey <TSource, TDestination>
                  (
                      sourceMapTypeDef: srcMapTypeDef,
                      destinationMapTypeDef: dstMapTypeDef,
                      autoMapperConfigDetails: configuationDetails,
                      mappingConfiguration: mappingConfiguration,
                      autoMapperBuilder: autoMapperBuilder);

            IAutoMapperRequestKeyGen response_AutoMapperRequestKey
                = RegisterAutoMapperRequest(autoMapperRequestKey);

            return((IAutoMapperRequestKey <TSource, TDestination>)response_AutoMapperRequestKey);
        }
        public static IAutoMapperBuilder AddRalatedType(this IAutoMapperBuilder builder, Type ralatedType)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddRalatedTypes(new[] { ralatedType }));
        }
        public static IAutoMapperBuilder AddProfileType <T>(this IAutoMapperBuilder builder) where T : Profile
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddProfileType(typeof(T)));
        }
        public static IAutoMapperBuilder AddAssemblies(this IAutoMapperBuilder builder, params Assembly[] assemblies)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddAssemblies((IEnumerable <Assembly>)assemblies);
            return(builder);
        }
        public static IAutoMapperBuilder AddProfileType(this IAutoMapperBuilder builder, Type profileType)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddProfileTypes(new[] { profileType });

            return(builder);
        }
        public static IAutoMapperBuilder AddAssembly(this IAutoMapperBuilder builder, Assembly assembly)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            builder.AddAssemblies(new[] { assembly });

            return(builder);
        }
Exemplo n.º 7
0
        //public Func<TDestination, TSource> SourceConstructor => MappingConfiguration.SourceConstructor;
        //public Func<TSource, TDestination> DestinationConstructor => MappingConfiguration.DestinationConstructor;

        #endregion

        #region Constructor

        public AutoMapperRequestKey
        (
            IMapTypeDefinition sourceMapTypeDef,
            IMapTypeDefinition destinationMapTypeDef,
            IAutoMapperConfigDetails autoMapperConfigDetails,
            IConfigureAMapper <TSource, TDestination> mappingConfiguration,
            IAutoMapperBuilder <TSource, TDestination> autoMapperBuilder
        )
            : base
            (
                sourceMapTypeDef,
                destinationMapTypeDef,
                autoMapperConfigDetails,
                autoMapperBuilder.AutoMapperBuilderGen
            )
        {
            MappingConfiguration = mappingConfiguration;
        }
Exemplo n.º 8
0
        private IAutoMapperBuilder <TSource, TDestination> BuildTheAutoMapperBuilder <TSource, TDestination>(IHaveAMapperConfigurationStep configStarterForThisRequest)
        {
            // TODO: check to make sure that the "configStarterForThisRequest" value is being sent to the correct place.

            // TODO: Make the method: GetAutoMapperBuilder on IAutoMapperBuilderProvider accept a
            // configStarterForThisRequest parameter.
            // Then create a new interface: IBuildMapperConfigurations_Provider
            // an implementation of this interface can be injected into the IBuildAutoMapper instance
            // so that the AutoMapperBuilder can create the ConfigurationBuilder for this request
            // and give it the configStarterForThisRequest value.

            // Create a Configuration Builder for this request.
            IMapperConfigurationBuilder <TSource, TDestination> propBagMapperConfigurationBuilder
                = new SimpleMapperConfigurationBuilder <TSource, TDestination>(configStarter: configStarterForThisRequest);

            // Create a MapperBuilder for this request.
            IAutoMapperBuilder <TSource, TDestination> autoMapperBuilder
                = _autoMapperBuilderProvider.GetAutoMapperBuilder <TSource, TDestination>
                  (
                      propBagMapperConfigurationBuilder
                  );

            return(autoMapperBuilder);
        }
 public WeatherForecastController(IAutoMapperBuilder autoMapperBuilder, IMapper mapper)
 {
     //_mapper = autoMapperBuilder.Build();
     _mapper = mapper;
 }
Exemplo n.º 10
0
 public static IAutoMapperBuilder AddProfile <T>(this IAutoMapperBuilder me) where T : Profile
 {
     me.Services.AddTransient <Profile, T>();
     return(me);
 }
 public static IAutoMapperBuilder AddRalatedType <T>(this IAutoMapperBuilder builder)
 {
     return(builder.AddRalatedType(typeof(T)));
 }