From dcac97fe3b849714779653bbbcd2ebed8c95bb36 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 10 Apr 2015 11:42:23 -0700 Subject: [PATCH] React to configuration model change --- src/MusicStore.Spa/Startup.cs | 6 +++--- src/MusicStore/Models/SampleData.cs | 5 ++++- src/MusicStore/Startup.cs | 5 +++-- src/MusicStore/StartupNtlmAuthentication.cs | 5 +++-- src/MusicStore/StartupOpenIdConnect.cs | 5 +++-- .../compiler/shared/Mocks/StartupOpenIdConnectTesting.cs | 5 +++-- test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs | 2 +- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/MusicStore.Spa/Startup.cs b/src/MusicStore.Spa/Startup.cs index c374ca9d37..9557d33137 100644 --- a/src/MusicStore.Spa/Startup.cs +++ b/src/MusicStore.Spa/Startup.cs @@ -5,17 +5,17 @@ using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.Data.Entity; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Runtime; using MusicStore.Apis; using MusicStore.Models; - namespace MusicStore.Spa { public class Startup { - public Startup() + public Startup(IApplicationEnvironment env) { - Configuration = new Configuration() + Configuration = new Configuration(env.ApplicationBasePath) .AddJsonFile("Config.json") .AddEnvironmentVariables(); } diff --git a/src/MusicStore/Models/SampleData.cs b/src/MusicStore/Models/SampleData.cs index f05e67a993..02fd4d98aa 100644 --- a/src/MusicStore/Models/SampleData.cs +++ b/src/MusicStore/Models/SampleData.cs @@ -8,6 +8,7 @@ using Microsoft.Data.Entity; using Microsoft.Data.Entity.SqlServer; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Runtime; namespace MusicStore.Models { @@ -86,7 +87,9 @@ namespace MusicStore.Models /// private static async Task CreateAdminUser(IServiceProvider serviceProvider) { - var configuration = new Configuration() + var appEnv = serviceProvider.GetService(); + + var configuration = new Configuration(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index 7b3907c29e..5aed990a29 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -9,17 +9,18 @@ using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; using MusicStore.Models; namespace MusicStore { public class Startup { - public Startup() + public Startup(IApplicationEnvironment env) { //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 Configuration() + Configuration = new Configuration(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. } diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index f5bcd8409a..94fc6dc3e3 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -10,6 +10,7 @@ using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; using Microsoft.Net.Http.Server; using MusicStore.Models; @@ -30,11 +31,11 @@ namespace MusicStore /// public class StartupNtlmAuthentication { - public StartupNtlmAuthentication() + public StartupNtlmAuthentication(IApplicationEnvironment env) { //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 Configuration() + Configuration = new Configuration(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. } diff --git a/src/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/StartupOpenIdConnect.cs index ab641c7004..fbc05c6542 100644 --- a/src/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/StartupOpenIdConnect.cs @@ -9,6 +9,7 @@ using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; using MusicStore.Models; namespace MusicStore @@ -28,11 +29,11 @@ namespace MusicStore /// public class StartupOpenIdConnect { - public StartupOpenIdConnect() + public StartupOpenIdConnect(IApplicationEnvironment env) { //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 Configuration() + Configuration = new Configuration(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs index ac71431752..1032729aab 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupOpenIdConnectTesting.cs @@ -10,6 +10,7 @@ using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; using MusicStore.Mocks.Common; using MusicStore.Mocks.OpenIdConnect; using MusicStore.Models; @@ -18,11 +19,11 @@ namespace MusicStore { public class StartupOpenIdConnectTesting { - public StartupOpenIdConnectTesting() + public StartupOpenIdConnectTesting(IApplicationEnvironment env) { //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 Configuration() + Configuration = new Configuration(env.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index a7a0b0cda8..7185bb65ea 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -29,7 +29,7 @@ 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 Configuration() + Configuration = new Configuration(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.