You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs

70 lines
2.2 KiB

using AbpDesk.EntityFrameworkCore;
using AbpDesk.Web.Mvc.Navigation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Volo.Abp;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
namespace AbpDesk.Web.Mvc
{
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpDeskApplicationModule),
typeof(AbpDeskEntityFrameworkCoreModule))]
public class AbpDeskWebMvcModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
var hostingEnvironment = services.GetSingletonInstance<IHostingEnvironment>();
var configuration = BuildConfiguration(hostingEnvironment);
AbpDeskDbConfigurer.Configure(services, configuration);
services.Configure<NavigationOptions>(options =>
{
options.MenuContributors.Add(new MainMenuContributor());
});
services.AddMvc();
services.AddAssemblyOf<AbpDeskWebMvcModule>();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
context.GetLoggerFactory().AddConsole();
if (context.GetEnvironment().IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
return builder.Build();
}
}
}