Update AbpWebAssemblyHostBuilderExtensions.cs

pull/10928/head
maliming 4 years ago
parent 2212157f03
commit 9ee07d7019
No known key found for this signature in database
GPG Key ID: 096224957E51C89E

@ -17,6 +17,30 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting;
public static class AbpWebAssemblyHostBuilderExtensions
{
public static async Task<IAbpApplicationWithExternalServiceProvider> AddApplicationAsync<TStartupModule>(
[NotNull] this WebAssemblyHostBuilder builder,
Action<AbpWebAssemblyApplicationCreationOptions> options)
where TStartupModule : IAbpModule
{
Check.NotNull(builder, nameof(builder));
// Related this commit(https://github.com/dotnet/aspnetcore/commit/b99d805bc037fcac56afb79abeb7d5a43141c85e)
// Microsoft.AspNetCore.Blazor.BuildTools has been removed in net 5.0.
// This call may be removed when we find a suitable solution.
// System.Runtime.CompilerServices.AsyncStateMachineAttribute
Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add<AsyncStateMachineAttribute>();
builder.Services.AddSingleton<IConfiguration>(builder.Configuration);
builder.Services.AddSingleton(builder);
var application = await builder.Services.AddApplicationAsync<TStartupModule>(opts =>
{
options?.Invoke(new AbpWebAssemblyApplicationCreationOptions(builder, opts));
});
return application;
}
public static IAbpApplicationWithExternalServiceProvider AddApplication<TStartupModule>(
[NotNull] this WebAssemblyHostBuilder builder,
Action<AbpWebAssemblyApplicationCreationOptions> options)
@ -51,7 +75,7 @@ public static class AbpWebAssemblyHostBuilderExtensions
((ComponentsClientScopeServiceProviderAccessor)serviceProvider
.GetRequiredService<IClientScopeServiceProviderAccessor>()).ServiceProvider = serviceProvider;
application.Initialize(serviceProvider);
await application.InitializeAsync(serviceProvider);
await InitializeModulesAsync(serviceProvider);
await SetCurrentLanguageAsync(serviceProvider);
}

Loading…
Cancel
Save