Esempio n. 1
0
        private void AutoMapperSetup(IServiceCollection services)
        {
            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

            var config = new AutoMapper.Configuration.MapperConfigurationExpression();

            config.AddProfile <ManagerMappingProfile>();
            config.AddProfile <DTOMappingProfile>();

            Mapper.Initialize(config);

            Mapper.AssertConfigurationIsValid();
        }
Esempio n. 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            #region mapper
            //var config = new AutoMapper.MapperConfiguration(cfg =>
            //{
            //    cfg.AddProfile<Book2BookDtoProfile>();
            //});
            //var mapper = config.CreateMapper();

            //AutoMapper.Mapper.Initialize(cfg =>
            //{
            //    cfg.AddProfile<Book2BookDtoProfile>();
            //});

            var cfg = new AutoMapper.Configuration.MapperConfigurationExpression();
            cfg.AddProfile <Book2BookDtoProfile>();
            AutoMapper.Mapper.Initialize(cfg);
            #endregion
        }
Esempio n. 3
0
        private void AutoMapperConfigure()
        {
            var configurationExpression = new AutoMapper.Configuration.MapperConfigurationExpression();

            configurationExpression.AddProfile <PagedListMappingProfile>();

            Mapper.Initialize(configurationExpression);
        }
Esempio n. 4
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;


            var express = new AutoMapper.Configuration.MapperConfigurationExpression();

            express.AddProfile <DtoMappings>();
            Mapper.Initialize(express);
        }
Esempio n. 5
0
        /// <summary>
        /// 初始化对象映射关系
        /// </summary>
        public static void InitializeMappers()
        {
            var cfg = new AutoMapper.Configuration.MapperConfigurationExpression();

            foreach (Type proType in AssemblyHelper.GetTypeByInterface <IAutoProfile>())
            {
                cfg.AddProfile(proType);
            }

            AutoMapper.Mapper.Initialize(cfg);
        }
        /// <summary>
        /// 初始化对象映射关系
        /// </summary>
        static public void RegisterAutoMapper()
        {
            var cfg = new AutoMapper.Configuration.MapperConfigurationExpression();

            foreach (Type proType in AssemblyProvider.GetTypeByInterface <IDBAutoProfile>())
            {
                cfg.AddProfile(proType);
            }

            cfg.SourceMemberNamingConvention      = new LowerUnderscoreNamingConvention(); // 命名是小写并包含下划线
            cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();      // 帕斯卡命名规则

            Configuration = new MapperConfiguration(cfg);
            Mapper        = Configuration.CreateMapper();
        }
        public void InstallServices(IServiceCollection services, IConfiguration configuration)
        {
            var cfg = new AutoMapper.Configuration.MapperConfigurationExpression();

            cfg.AddProfile <AccountProfile>();
            cfg.AddProfile <BrojKorisnikaLogProfile>();
            cfg.AddProfile <ComboBoxProfile>();
            cfg.AddProfile <FeedsProfile>();
            cfg.AddProfile <GradoviProfile>();
            cfg.AddProfile <ObjaveProfile>();
            cfg.AddProfile <PrijavaProfile>();
            cfg.AddProfile <ReportProfile>();
            cfg.AddProfile <StatistikeProfile>();
            cfg.AddProfile <TakmicenjeProfile>();
            cfg.AddProfile <TakmicenjeVMProfile>();

            var config = new MapperConfiguration(cfg);

            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }