diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs b/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs index 32c298006..90d9afbb4 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs @@ -33,10 +33,9 @@ builder.Host.AddAppSettingsSecretsJson() config.AddJsonFile($"appsettings.{dbProvider}.json", optional: true); } - var configuration = config.Build(); - if (configuration.GetValue("AgileConfig:IsEnabled", false)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs index 09109c623..4aa445dd7 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.AuthServer/Program.cs b/aspnet-core/services/LY.MicroService.AuthServer/Program.cs index 267966d6b..f5e9a6635 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/Program.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs index e8aa0a545..6a7799229 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs @@ -26,12 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/Program.cs index 89ed05dfe..41e5f2812 100644 --- a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/Program.cs @@ -28,11 +28,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.IdentityServer/Program.cs b/aspnet-core/services/LY.MicroService.IdentityServer/Program.cs index 660b0b7d0..d7fa19c18 100644 --- a/aspnet-core/services/LY.MicroService.IdentityServer/Program.cs +++ b/aspnet-core/services/LY.MicroService.IdentityServer/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs index 0009be645..d63a6d280 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs index 4920277fd..b20c8df3e 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs index 5643184b9..3a5cd0902 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs @@ -25,11 +25,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs index e5b9090d9..56443ae09 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs index 47df8891e..1d8777a4d 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/Program.cs index 50ac30889..03fed305e 100644 --- a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/Program.cs @@ -1,6 +1,7 @@ using LY.MicroService.WechatManagement; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; @@ -19,11 +20,9 @@ try .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs index a568fbbd6..1b7440bc2 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs @@ -26,11 +26,9 @@ public class Program .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) => diff --git a/aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs b/aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs index f7939c1f4..7b5b86ab8 100644 --- a/aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs +++ b/aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs @@ -21,13 +21,9 @@ try .UseAutofac() .ConfigureAppConfiguration((context, config) => { - var agileConfig = context.Configuration.GetSection("AgileConfig");//IsEnabled - if (agileConfig.Exists()) + if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) { - if (agileConfig.GetValue("IsEnabled", false)) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); - } + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); } }) .UseSerilog((context, provider, config) =>