当前位置: 首页>>代码示例>>C#>>正文


C# IServiceCollection.AddAutoMapper方法代码示例

本文整理汇总了C#中IServiceCollection.AddAutoMapper方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddAutoMapper方法的具体用法?C# IServiceCollection.AddAutoMapper怎么用?C# IServiceCollection.AddAutoMapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceCollection的用法示例。


在下文中一共展示了IServiceCollection.AddAutoMapper方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<AppSettings>(opt => Configuration.GetSection("AppSettings"));

            services.AddMvc()
                .AddVersionEndpoint();

            services.AddBusinessServices();
            services.AddAutoMapper();
            services.AddSwaggerGen();
        }
开发者ID:digipolisantwerp,项目名称:generator-dgp-web-aspnetcore_yeoman,代码行数:11,代码来源:Startup.cs

示例2: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            // Check out ExampleController to find out how these configs are injected into other classes
            services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));

            //--dataaccess-startupServices--

            services.AddMvc()
                .AddVersionEndpoint();

            services.AddBusinessServices();
            services.AddAutoMapper();
                
            services.AddSwaggerGen();

            services.AddGlobalErrorHandling<ApiExceptionMapper>();
		}
开发者ID:digipolisantwerp,项目名称:generator-dgp-api-aspnetcore_yeoman,代码行数:17,代码来源:Startup.cs

示例3: ConfigureServices

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var path = PlatformServices.Default.Application.ApplicationBasePath;

            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<UkuContext>(options =>
                    options.UseSqlite("Filename=" + Path.Combine(path, "uku.db")));

            // Add framework services.
            services.AddMvc();

            // Need to do this if the UkuContext does not inlcude a constructor which takes options. That's only a problem for the interface though, not the concrete type. No idea why.
            //services.AddTransient<IUkuContext, UkuContext>(p => p.GetRequiredService<UkuContext>());

            services
                .AddScoped<IUkuContext, UkuContext>()
                .AddScoped<IAlbumService, AlbumService>();

            services.AddAutoMapper();
        }
开发者ID:SiCannon,项目名称:Aspnet5ProofOfConcept,代码行数:22,代码来源:Startup.cs

示例4: ConfigureServices

        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), o => o.EnableRetryOnFailure()));

            services.Configure<DRSConfig>(Configuration.GetSection("DRS"));

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            //services.AddReact();

            services
                .AddMvc(
                    options =>
                    {
                        options.Conventions.Add(new FeatureConvention());
                        options.Filters.Add(new ValidateModelStateFilter());
                        options.Filters.Add(new ApiExceptionFilter());
                    })
                .AddRazorOptions(options =>
                {
                    // {0} - Action Name
                    // {1} - Controller Name
                    // {2} - Area Name
                    // {3} - Feature Name
                    //options.AreaViewLocationFormats.Clear();
                    options.AreaViewLocationFormats.Add("/Areas/{2}/Features/{3}/{1}/{0}.cshtml");
                    options.AreaViewLocationFormats.Add("/Areas/{2}/Features/{3}/{0}.cshtml");
                    options.AreaViewLocationFormats.Add("/Areas/{2}/Features/Shared/{0}.cshtml");
                    options.AreaViewLocationFormats.Add("/Areas/Shared/{0}.cshtml");
                    // replace normal view location entirely
                    //options.ViewLocationFormats.Clear();
                    options.ViewLocationFormats.Add("/Features/{3}/{1}/{0}.cshtml");
                    options.ViewLocationFormats.Add("/Features/{3}/{0}.cshtml");
                    options.ViewLocationFormats.Add("/Features/Shared/{0}.cshtml");

                    options.ViewLocationExpanders.Add(new FeatureViewLocationExpander());
                })
                .AddJsonOptions(
                    options =>
                    {
                        options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    })
                .AddFluentValidation(cfg => { cfg.RegisterValidatorsFromAssemblyContaining<Startup>(); });

            services.AddAutoMapper(typeof(Startup));

            Mapper.AssertConfigurationIsValid();

            services.AddMediatR(typeof(Startup));

            var container = new Container(cfg => { cfg.AddRegistry<WebRegistry>(); });

            // populates structuremap with .NET services

            container.Populate(services);

            return container.GetInstance<IServiceProvider>();
        }
开发者ID:lruckman,项目名称:DRS,代码行数:63,代码来源:Startup.cs

示例5: ConfigureServices

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(JsonExceptionFilter));
            });

            services.AddDbContext<AppDbContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddMediatR(typeof(Startup).GetTypeInfo().Assembly);

            services.AddAutoMapper();

            services.AddOptions();
            services.Configure<TokenProviderOptions>(Configuration.GetSection("tokenOptions"));
        }
开发者ID:yarrgh,项目名称:hackettrecipes,代码行数:18,代码来源:Startup.cs


注:本文中的IServiceCollection.AddAutoMapper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。