Simplify MVC template web module class.

pull/732/head
Halil ibrahim Kalkan 7 years ago
parent 5a5a495ec4
commit 3e95ce3811

@ -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<DbConnectionOptions>(options =>
//<TEMPLATE-REMOVE IF-NOT='EntityFrameworkCore'>
Configure<AbpDbContextOptions>(options =>
{
options.ConnectionStrings.Default = configuration.GetConnectionString("Default");
options.UseSqlServer();
});
//<TEMPLATE-REMOVE IF-NOT='EntityFrameworkCore'>
services.Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
//</TEMPLATE-REMOVE>
}
private static void ConfigureAutoMapper(IServiceCollection services)
private void ConfigureAutoMapper()
{
services.Configure<AbpAutoMapperOptions>(options =>
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<MyProjectNameWebAutoMapperProfile>();
});
}
private static void ConfigureVirtualFileSystem(IServiceCollection services, IHostingEnvironment hostingEnvironment)
private void ConfigureVirtualFileSystem(IHostingEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{
services.Configure<VirtualFileSystemOptions>(options =>
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPyhsical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar)));
//<TEMPLATE-REMOVE>
@ -116,9 +112,9 @@ namespace MyCompanyName.MyProjectName
}
}
private static void ConfigureLocalizationServices(IServiceCollection services)
private void ConfigureLocalizationServices()
{
services.Configure<AbpLocalizationOptions>(options =>
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<MyProjectNameResource>()
@ -134,23 +130,23 @@ namespace MyCompanyName.MyProjectName
});
}
private static void ConfigureNavigationServices(IServiceCollection services)
private void ConfigureNavigationServices()
{
services.Configure<NavigationOptions>(options =>
Configure<NavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
}
private static void ConfigureAutoApiControllers(IServiceCollection services)
private void ConfigureAutoApiControllers()
{
services.Configure<AbpAspNetCoreMvcOptions>(options =>
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
});
}
private static void ConfigureSwaggerServices(IServiceCollection services)
private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddSwaggerGen(
options =>

Loading…
Cancel
Save