From 54ddefe88c2c8d80009b191dea81407083610b12 Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Fri, 22 May 2015 06:14:17 -0700 Subject: [PATCH] React to aspnet/Configuration #194 --- src/MusicStore.Spa/Startup.cs | 3 ++- src/MusicStore/Models/SampleData.cs | 3 ++- src/MusicStore/Program.cs | 5 +++-- src/MusicStore/Startup.cs | 3 ++- src/MusicStore/StartupNtlmAuthentication.cs | 3 ++- src/MusicStore/StartupOpenIdConnect.cs | 3 ++- .../compiler/shared/Mocks/StartupOpenIdConnectTesting.cs | 3 ++- test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs | 3 ++- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/MusicStore.Spa/Startup.cs b/src/MusicStore.Spa/Startup.cs index 82849a2638..99ce771f1d 100644 --- a/src/MusicStore.Spa/Startup.cs +++ b/src/MusicStore.Spa/Startup.cs @@ -15,9 +15,10 @@ namespace MusicStore.Spa { public Startup(IApplicationEnvironment env) { - Configuration = new ConfigurationSection(env.ApplicationBasePath) + var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("Config.json") .AddEnvironmentVariables(); + Configuration = builder.Build(); } public Microsoft.Framework.Configuration.IConfiguration Configuration { get; set; } diff --git a/src/MusicStore/Models/SampleData.cs b/src/MusicStore/Models/SampleData.cs index 8f378ffe07..2cd87f241d 100644 --- a/src/MusicStore/Models/SampleData.cs +++ b/src/MusicStore/Models/SampleData.cs @@ -89,9 +89,10 @@ namespace MusicStore.Models { var appEnv = serviceProvider.GetService(); - var configuration = new ConfigurationSection(appEnv.ApplicationBasePath) + var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); + var configuration = builder.Build(); //const string adminRole = "Administrator"; diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs index 5d7550f1cf..86de328e29 100644 --- a/src/MusicStore/Program.cs +++ b/src/MusicStore/Program.cs @@ -21,8 +21,9 @@ namespace MusicStore public Task Main(string[] args) { //Add command line configuration source to read command line parameters. - var config = new ConfigurationSection(); - config.AddCommandLine(args); + var builder = new ConfigurationBuilder(); + builder.AddCommandLine(args); + var config = builder.Build(); using (new WebHostBuilder(_serviceProvider, config) .UseServer("Microsoft.AspNet.Server.WebListener") diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index a750693ac4..f68075d951 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -23,10 +23,11 @@ namespace MusicStore { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. - Configuration = new ConfigurationSection(env.ApplicationBasePath) + var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. + Configuration = builder.Build(); _platform = new Platform(runtimeEnvironment); } diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index 33c0fde62f..4036bebe39 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -36,9 +36,10 @@ namespace MusicStore { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. - Configuration = new ConfigurationSection(env.ApplicationBasePath) + var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. + Configuration = builder.Build(); } public IConfiguration Configuration { get; private set; } diff --git a/src/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/StartupOpenIdConnect.cs index 08665c5eea..ebe34ecc38 100644 --- a/src/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/StartupOpenIdConnect.cs @@ -36,10 +36,11 @@ namespace MusicStore { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. - Configuration = new ConfigurationSection(env.ApplicationBasePath) + var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. + Configuration = builder.Build(); _platform = new Platform(runtimeEnvironment); } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs index 9cea3a2dd6..552fd843b1 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs @@ -27,10 +27,11 @@ namespace MusicStore { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. - Configuration = new ConfigurationSection(env.ApplicationBasePath) + var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. + Configuration = builder.Build(); _runtimeEnvironment = runtimeEnvironment; } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index 28da6a0025..96a451ded8 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -33,11 +33,12 @@ namespace MusicStore { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. - Configuration = new ConfigurationSection(appEnvironment.ApplicationBasePath) + var builder = new ConfigurationBuilder(appEnvironment.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables() //All environment variables in the process's context flow in as configuration values. .AddJsonFile("configoverride.json", optional: true); // Used to override some configuration parameters that cannot be overridden by environment. + Configuration = builder.Build(); _runtimeEnvironment = runtimeEnvironment; }