private static void RegisterMappings(IMapperConfigurationExpression configure)
        {
            configure.AddProfiles(typeof(AutoMapperMiddleware).GetTypeInfo().Assembly);     // Dynamically load all configurations

            // ...or do it manually below. Example: https://github.com/AutoMapper/AutoMapper/wiki/Configuration
            // ...or see examples in Profiles directory.
        }
Exemple #2
0
        private void FindAndAddProfiles(IMapperConfigurationExpression configuration, List <Assembly> assemblies)
        {
            var profileType      = typeof(Profile);
            var filterAssemblies = assemblies
                                   .Where(t => !t.FullName.ToUpper().StartsWith("AUTOMAPPER"))
                                   .Where(t => t.GetTypes().Any(inner => profileType.IsAssignableFrom(inner) && inner != profileType)).ToArray();

            configuration.AddProfiles(filterAssemblies);
        }
        /// <summary>
        /// 注入程序集Mappings
        /// </summary>
        /// <param name="config"><see cref="IMapperConfigurationExpression"/></param>
        /// <returns></returns>
        public static void RegisterAllMappings(this IMapperConfigurationExpression config, Assembly assembly)
        {
            //获取所有的程序集
            List <AssemblyName> assemblys = assembly
                                            .GetReferencedAssemblies().ToList();//获取所有引用程序集

            assemblys.Add(assembly.GetName());

            //获取所有IProfile实现类
            IEnumerable <Type> allType = assemblys
                                         .Select(f => Assembly.Load(f))
                                         .SelectMany(y => y.ExportedTypes)
                                         .Where(type => typeof(Profile).GetTypeInfo().IsAssignableFrom(type) && !type.IsAbstract && type.Module.Name != "AutoMapper.dll")
                                         .ToList();

            foreach (var type in allType)
            {
                //注册映射
                config.AddProfiles(type); // Initialise each Profile classe
            }
        }
        public static void Initialize(IMapperConfigurationExpression cfg)
        {
            cfg.AddProfiles(typeof(AutoMapperConfig).Assembly);

            cfg.CreateMap <Garage, GarageDto>();
            cfg.CreateMap <Cars, CarsDto>();

            cfg.CreateMap <Person, PersonDto>();
            cfg.CreateMap <PersonDto, Person>();

            cfg.CreateMap <Clients, ClientsDto>();
            cfg.CreateMap <ClientsDto, Clients>();

            cfg.CreateMap <VisitRepair, VisitRepairDto>();
            cfg.CreateMap <VisitRepairDto, VisitRepair>();

            cfg.CreateMap <VisitCarCard, VisitCarCardDto>();
            cfg.CreateMap <VisitCarCardDto, VisitCarCard>();

            cfg.CreateMap <ServiceList, ServiceListDto>();
            cfg.CreateMap <ServiceListDto, ServiceList>();
        }
Exemple #5
0
        public static void Init(IMapperConfigurationExpression cfg)
        {
            var assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            cfg.AddProfiles(assemblyName);
        }
 public static void Configure(IMapperConfigurationExpression cfg)
 {
     cfg.AddProfiles(Assembly.GetExecutingAssembly());
 }
 private static void UseManageIpAddressesApiMapping(IMapperConfigurationExpression config)
 {
     config.AddProfiles(typeof(WebApiMapper).Assembly);
 }
Exemple #8
0
 public static void AddProfiles <T>(this IMapperConfigurationExpression cfg)
 {
     cfg.AddProfiles(typeof(T).GetTypeInfo().Assembly);
 }
Exemple #9
0
 private static void AspNetCoreGAEWebApiMapping(IMapperConfigurationExpression config)
 {
     config.AddProfiles(typeof(WebApiAutoMapper).Assembly);
 }
Exemple #10
0
 /// <summary>
 /// Registrar perfis de mapeamento automaticamente
 /// </summary>
 /// <param name="mc"></param>
 private static void RegistrarPerfisMapeamentos(IMapperConfigurationExpression mc)
 {
     mc.AddProfiles(Assembly.GetExecutingAssembly());
 }
Exemple #11
0
 public void ConfigureMapping(IMapperConfigurationExpression config)
 {
     config.AddProfiles(this.GetType().Assembly);
 }