Browse Source

Change `EnvironmentName` on `PreConfigureServices` method.

pull/14842/head
maliming 4 years ago
parent
commit
e0501a3ad9
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 12
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs
  2. 5
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/AbpAspNetCoreModule.cs
  3. 9
      framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs

12
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs

@ -24,6 +24,12 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var abpHostEnvironment = context.Services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName = context.Services.GetWebAssemblyHostEnvironment().Environment;
}
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientBuildActions.Add((_, builder) =>
@ -35,12 +41,6 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
var abpHostEnvironment = context.Services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName = context.Services.GetWebAssemblyHostEnvironment().Environment;
}
context.Services
.GetHostBuilder().Logging
.AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services));

5
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/AbpAspNetCoreModule.cs

@ -29,14 +29,17 @@ namespace Volo.Abp.AspNetCore;
)]
public class AbpAspNetCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var abpHostEnvironment = context.Services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName = context.Services.GetHostingEnvironment().EnvironmentName;
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAuthorization();
Configure<AbpAuditingOptions>(options =>

9
framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs

@ -67,10 +67,13 @@ public abstract class AbpApplicationBase : IAbpApplication
ConfigureServices();
}
var abpHostEnvironment = services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
if (options.Environment.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName = Environments.Production;
var abpHostEnvironment = services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName = Environments.Production;
}
}
}

Loading…
Cancel
Save