Browse Source
Add `Optional` and `ReloadOnChange` to `AbpConfigurationBuilderOptions`.
pull/13728/head
maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
2 changed files with
12 additions and
2 deletions
-
framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/AbpConfigurationBuilderOptions.cs
-
framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs
|
|
|
@ -21,6 +21,16 @@ public class AbpConfigurationBuilderOptions |
|
|
|
/// </summary>
|
|
|
|
public string FileName { get; set; } = "appsettings"; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the file is optional, Default value: true.
|
|
|
|
/// </summary>
|
|
|
|
public bool Optional { get; set; } = true; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the configuration should be reloaded if the file changes, Default value: true.
|
|
|
|
/// </summary>
|
|
|
|
public bool ReloadOnChange { get; set; } = true; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Environment name. Generally used "Development", "Staging" or "Production".
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -18,11 +18,11 @@ public static class ConfigurationHelper |
|
|
|
|
|
|
|
var builder = new ConfigurationBuilder() |
|
|
|
.SetBasePath(options.BasePath) |
|
|
|
.AddJsonFile(options.FileName + ".json", optional: true, reloadOnChange: true); |
|
|
|
.AddJsonFile(options.FileName + ".json", optional: options.Optional, reloadOnChange: options.ReloadOnChange); |
|
|
|
|
|
|
|
if (!options.EnvironmentName.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: true, reloadOnChange: true); |
|
|
|
builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: options.Optional, reloadOnChange: options.ReloadOnChange); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.EnvironmentName == "Development") |
|
|
|
|