using System.Collections.Generic; using System.Globalization; using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using DashboardDemo.Localization; using DashboardDemo.Web; using DashboardDemo.Web.Menus; using Volo.Abp; using Volo.Abp.AspNetCore.TestBase; using Volo.Abp.Localization; using Volo.Abp.Validation.Localization; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; namespace DashboardDemo { [DependsOn( typeof(AbpAspNetCoreTestBaseModule), typeof(DashboardDemoWebModule), typeof(DashboardDemoApplicationTestModule) )] public class DashboardDemoWebTestModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { context.Services.PreConfigure(builder => { builder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(DashboardDemoWebModule).Assembly)); }); } public override void ConfigureServices(ServiceConfigurationContext context) { ConfigureLocalizationServices(context.Services); ConfigureNavigationServices(context.Services); } private static void ConfigureLocalizationServices(IServiceCollection services) { var cultures = new List { new CultureInfo("en"), new CultureInfo("tr") }; services.Configure(options => { options.DefaultRequestCulture = new RequestCulture("en"); options.SupportedCultures = cultures; options.SupportedUICultures = cultures; }); services.Configure(options => { options.Resources .Get() .AddBaseTypes( typeof(AbpValidationResource), typeof(AbpUiResource) ); }); } private static void ConfigureNavigationServices(IServiceCollection services) { services.Configure(options => { options.MenuContributors.Add(new DashboardDemoMenuContributor()); }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); //app.UseErrorPage(); app.UseVirtualFiles(); app.UseAuthentication(); app.UseRequestLocalization(app.ApplicationServices.GetRequiredService>().Value); app.UseMvcWithDefaultRouteAndArea(); } } }