From 3e95ce3811c623dd4881936292293055e0f1b745 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 11 Jan 2019 17:21:52 +0300 Subject: [PATCH] Simplify MVC template web module class. --- .../MyProjectNameWebModule.cs | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 82813d892d..87b306e63d 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -3,7 +3,6 @@ using System.Linq; using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MyCompanyName.MyProjectName.EntityFrameworkCore; using MyCompanyName.MyProjectName.Localization.MyProjectName; @@ -21,7 +20,6 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.Autofac; using Volo.Abp.AutoMapper; -using Volo.Abp.Data; using Volo.Abp.Identity; using Volo.Abp.Identity.Web; using Volo.Abp.Localization; @@ -66,40 +64,38 @@ namespace MyCompanyName.MyProjectName var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); - ConfigureDatabaseServices(context.Services, configuration); - ConfigureAutoMapper(context.Services); - ConfigureVirtualFileSystem(context.Services, hostingEnvironment); - ConfigureLocalizationServices(context.Services); - ConfigureNavigationServices(context.Services); - ConfigureAutoApiControllers(context.Services); + ConfigureDatabaseServices(); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureLocalizationServices(); + ConfigureNavigationServices(); + ConfigureAutoApiControllers(); ConfigureSwaggerServices(context.Services); } - private static void ConfigureDatabaseServices(IServiceCollection services, IConfigurationRoot configuration) + private void ConfigureDatabaseServices() { - services.Configure(options => + // + Configure(options => { - options.ConnectionStrings.Default = configuration.GetConnectionString("Default"); + options.UseSqlServer(); }); - // - - services.Configure(options => { options.UseSqlServer(); }); // } - private static void ConfigureAutoMapper(IServiceCollection services) + private void ConfigureAutoMapper() { - services.Configure(options => + Configure(options => { options.AddProfile(); }); } - private static void ConfigureVirtualFileSystem(IServiceCollection services, IHostingEnvironment hostingEnvironment) + private void ConfigureVirtualFileSystem(IHostingEnvironment hostingEnvironment) { if (hostingEnvironment.IsDevelopment()) { - services.Configure(options => + Configure(options => { options.FileSets.ReplaceEmbeddedByPyhsical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); // @@ -116,9 +112,9 @@ namespace MyCompanyName.MyProjectName } } - private static void ConfigureLocalizationServices(IServiceCollection services) + private void ConfigureLocalizationServices() { - services.Configure(options => + Configure(options => { options.Resources .Get() @@ -134,23 +130,23 @@ namespace MyCompanyName.MyProjectName }); } - private static void ConfigureNavigationServices(IServiceCollection services) + private void ConfigureNavigationServices() { - services.Configure(options => + Configure(options => { options.MenuContributors.Add(new MyProjectNameMenuContributor()); }); } - private static void ConfigureAutoApiControllers(IServiceCollection services) + private void ConfigureAutoApiControllers() { - services.Configure(options => + Configure(options => { options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); }); } - private static void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureSwaggerServices(IServiceCollection services) { services.AddSwaggerGen( options =>