Ejemplo n.º 1
0
        private static IServiceCollection ConfigureAutoMapper(IServiceCollection services)
        {
            var mapper = new AutoMapperAdapter();

            mapper.Initialize();
            services.AddSingleton <IAutoMapper>(mapper);
            return(services);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="mapper"></param>
 /// <returns></returns>
 public static AutoMapperAdapter Initialize(AutoMapperAdapter mapper)
 {
     mapper.Initialize(new IAutoMapperTypeConfigurator[]
     {
         new ControlColorTypeConfigurator(),
         new SessionTypeConfigurator(),
     });
     return(mapper);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 对应用层服务进行初始化, 在程序启动执行
        /// 有关于 Mapper 对应关系配置文件初始化设置
        /// </summary>
        public void Initialize()
        {
            var profiles = (from a in AppDomain.CurrentDomain.GetAssemblies()
                            where a.FullName.StartsWith("ReportMS.DataTransferObjects", StringComparison.OrdinalIgnoreCase)
                            from t in a.GetTypes()
                            where t.BaseType == typeof(Profile)
                            select t).AsEnumerable();

            AutoMapperAdapter.Initialize(cfg =>
            {
                foreach (var item in profiles.Where(item => item.FullName != "AutoMapper.SelfProfiler`2"))
                {
                    cfg.AddProfile(Activator.CreateInstance(item) as Profile);
                }
            });
        }
Ejemplo n.º 4
0
        private void InitAutoMapper()
        {
            var loaders = GetServices <IAutoMapperLoader>();

            AutoMapperAdapter.Initialize(loaders);
        }
 /// <summary>初期化</summary>
 public static void Initialize(this AutoMapperAdapter mapper)
 => mapper.Initialize(new IAutoMapperTypeConfigurator[]
 {
     new ControlColorTypeConfigurator(),
     new SessionTypeConfigurator(),
 });