Reacting to Configuration changes

This commit is contained in:
Pranav K 2015-09-25 07:51:25 -07:00
parent c4097f8080
commit a3f24bcb1d
6 changed files with 28 additions and 22 deletions

View File

@ -81,9 +81,10 @@ namespace MusicStore.Models
{
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables();
var builder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables();
var configuration = builder.Build();
//const string adminRole = "Administrator";

View File

@ -24,10 +24,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.
var builder = new ConfigurationBuilder(applicationEnvironment.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
var builder = new ConfigurationBuilder()
.SetBasePath(applicationEnvironment.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
Configuration = builder.Build();
_platform = new Platform(runtimeEnvironment);

View File

@ -41,10 +41,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.
var builder = new ConfigurationBuilder(applicationEnvironment.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
var builder = new ConfigurationBuilder()
.SetBasePath(applicationEnvironment.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
Configuration = builder.Build();
}

View File

@ -39,10 +39,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.
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
var builder = new ConfigurationBuilder()
.SetBasePath(env.ApplicationBasePath)
.AddJsonFile("config.json")
//All environment variables in the process's context flow in as configuration values.
.AddEnvironmentVariables();
Configuration = builder.Build();
_platform = new Platform(runtimeEnvironment);

View File

@ -27,9 +27,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.
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
var builder = new ConfigurationBuilder()
.SetBasePath(env.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
Configuration = builder.Build();
_runtimeEnvironment = runtimeEnvironment;

View File

@ -31,10 +31,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.
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.
var builder = new ConfigurationBuilder()
.SetBasePath(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;