Exemple #1
0
 private void SetMapperConfiguration(IContext o, IMapperConfigurationExpression c)
 {
     c.ConstructServicesUsing(o.GetInstance);
     c.CreateMap <Guid, ShortGuid>().ConvertUsing(g => ShortGuid.Encode(g));
     c.CreateMap <ShortGuid, Guid>().ConvertUsing(sg => sg.ToGuid());
     o.GetAllInstances <Profile>().ForEach(c.AddProfile);
 }
Exemple #2
0
        public static void Configure(IServiceProvider provider, IMapperConfigurationExpression cfg)
        {
            cfg.AddProfile <DomainToViewModelMappingProfile>();
            cfg.AddProfile <ViewModelToDomainMappingProfile>();
            cfg.ConstructServicesUsing(type => ActivatorUtilities.CreateInstance(provider, type));

            //config.AssertConfigurationIsValid();
        }
        public static void RegisterMappings(IMapperConfigurationExpression config, params Assembly[] assemblies)
        {
            config.ConstructServicesUsing(t => DependencyResolver.Current.GetService(t));

            var types = Assembly.GetExecutingAssembly().GetExportedTypes();

            LoadStandardMappings(config, types);
            LoadCustomMappings(config, types);
        }
Exemple #4
0
        private static void ConfigureMapper(IMapperConfigurationExpression config, IComponentContext context)
        {
            context = context.Resolve <IComponentContext>();

            config.ConstructServicesUsing(context.Resolve);

            var appServicesToViewModelMappingProfile = new ViewModelsMappingProfile(context);

            config.AddProfile(appServicesToViewModelMappingProfile);
        }
        public static void Execute(IMapperConfigurationExpression config)
        {
            config.ConstructServicesUsing(t => DependencyResolver.Current.GetService(t));

            Type[] types = Assembly.GetExecutingAssembly().GetExportedTypes();

            LoadStandartMappings(config, types);

            LoadCustomMapping(config, types);
        }
 internal static void ConfigAction(
     this Container c,
     IMapperConfigurationExpression cfg,
     AutoMapperSimpleInjectorConfiguration serviceCfg)
 {
     serviceCfg.MapperConfigurationExpressionAction.Invoke(
         c,
         cfg);
     cfg.ConstructServicesUsing(c.GetInstance);
     cfg.AddMaps(serviceCfg.AssembliesToScan);
 }
Exemple #7
0
        private static void RegistrarMapeamentos(IServiceProvider provider, IMapperConfigurationExpression config)
        {
            config.ConstructServicesUsing(provider.GetService);

            config.AddProfile(provider.GetService <MapeadorDeDTODeColaborador>());
            config.AddProfile(provider.GetService <MapeadorDeDTODeAluno>());
            config.AddProfile(provider.GetService <MapeadorDeDTODeAlunoDoResponsavel>());
            config.AddProfile(provider.GetService <MapeadorDeDTODeResponsavel>());
            config.AddProfile(provider.GetService <MapeadorDeDTODeTurma>());
            config.AddProfile(provider.GetService <MapeadorDeDTODeLogin>());
            config.AddProfile(provider.GetService <MapeadorDeDTODePessoa>());
        }
        public static void Configure(IMapperConfigurationExpression cfg, Func <Type, object> resolverFunc = null)
        {
            cfg.AddProfile <CsvLineToWorkDayProfile>();

            cfg.AllowNullCollections = true;

            cfg.Advanced.AllowAdditiveTypeMapCreation = true;

            if (resolverFunc != null)
            {
                cfg.ConstructServicesUsing(resolverFunc);
            }
        }
Exemple #9
0
        public static void RegisterMappings(IMapperConfigurationExpression config, params Assembly[] assemblies)
        {
            config.ConstructServicesUsing(t => DependencyResolver.Current.GetService(t));
            var types = new List <Type>();

            foreach (var assembly in assemblies)
            {
                types.AddRange(assembly.GetExportedTypes());
            }

            LoadStandardMappings(config, types);
            LoadCustomMappings(config, types);
        }
Exemple #10
0
        private static void RegisterMappings(IMapperConfigurationExpression config, IEnumerable <Assembly> assemblies)
        {
            // TODO remove DependencyResolver because it has dependency to MVC
            config.ConstructServicesUsing(t => DependencyResolver.Current.GetService(t));

            var types = new List <Type>();

            foreach (var assembly in assemblies)
            {
                types.AddRange(assembly.GetExportedTypes());
            }

            LoadStandardMappings(config, types);
        }
        /// <summary>
        /// Compiles the options.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="assemblies">The assemblies.</param>
        /// <param name="cfg">The CFG.</param>
        private static void CompileOptions <T>(List <Assembly> assemblies, IMapperConfigurationExpression cfg) where T : Profile
        {
            var profiles = assemblies.Select(p => p.GetTypes().Where(x => typeof(T).IsAssignableFrom(x) && !x.IsAbstract));

            cfg.ConstructServicesUsing((s) => DIResolver.Get(s));

            foreach (var assemblyProfiles in profiles)
            {
                foreach (var assemblyProfile in assemblyProfiles)
                {
                    cfg.AddProfile(Activator.CreateInstance(assemblyProfile) as T);
                }
            }
            cfg.ForAllMaps((t, m) =>
            {
                m.ConstructUsing((x) => resolver(t, x));
            });
        }
 private void ConfigureAutoMapper(IServiceProvider serviceProvider, IMapperConfigurationExpression configuration)
 {
     configuration
     .ConstructServicesUsing(serviceProvider.GetService);
 }
 private static void GenerateMapperConfiguration(IMapperConfigurationExpression config)
 {
     config.ConstructServicesUsing(DependencyResolver.Current.GetService);
     config.AddProfile <ViewModelProfile>();
     config.AddProfile <DtoModelProfile>();
 }
 public virtual void Configure(IMapperConfigurationExpression mapperConfigExpression)
 {
     mapperConfigExpression.ConstructServicesUsing(type => DependencyManager.Resolve(type.GetTypeInfo()));
     mapperConfigExpression.ValidateInlineMaps    = false;
     mapperConfigExpression.CreateMissingTypeMaps = true;
 }