|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
@ -6,6 +7,7 @@ using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Volo.Abp;
|
|
|
|
|
using Volo.Abp.AspNetCore.Components.WebAssembly;
|
|
|
|
|
using Volo.Abp.AspNetCore.Mvc.Client;
|
|
|
|
|
using Volo.Abp.Modularity;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
|
|
|
|
@ -30,7 +32,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
|
|
|
|
|
return application;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async Task InitializeAsync(
|
|
|
|
|
public async static Task InitializeAsync(
|
|
|
|
|
[NotNull] this IAbpApplicationWithExternalServiceProvider application,
|
|
|
|
|
[NotNull] IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
@ -41,10 +43,29 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
|
|
|
|
|
|
|
|
|
|
using (var scope = serviceProvider.CreateScope())
|
|
|
|
|
{
|
|
|
|
|
foreach (var service in scope.ServiceProvider.GetServices<IAsyncInitialize>())
|
|
|
|
|
{
|
|
|
|
|
await service.InitializeAsync();
|
|
|
|
|
}
|
|
|
|
|
await InitializeModulesAsync(scope.ServiceProvider);
|
|
|
|
|
SetCurrentLanguage(scope);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async static Task InitializeModulesAsync(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
foreach (var service in serviceProvider.GetServices<IAsyncInitialize>())
|
|
|
|
|
{
|
|
|
|
|
await service.InitializeAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetCurrentLanguage(IServiceScope scope)
|
|
|
|
|
{
|
|
|
|
|
var configurationClient = scope.ServiceProvider.GetRequiredService<ICachedApplicationConfigurationClient>();
|
|
|
|
|
var configuration = configurationClient.Get();
|
|
|
|
|
var cultureName = configuration.Localization?.CurrentCulture?.CultureName;
|
|
|
|
|
if (!cultureName.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var culture = new CultureInfo(cultureName);
|
|
|
|
|
CultureInfo.DefaultThreadCurrentCulture = culture;
|
|
|
|
|
CultureInfo.DefaultThreadCurrentUICulture = culture;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|