Reacting to Configuration changes
This commit is contained in:
parent
c4097f8080
commit
a3f24bcb1d
|
|
@ -81,9 +81,10 @@ namespace MusicStore.Models
|
||||||
{
|
{
|
||||||
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
|
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(appEnv.ApplicationBasePath)
|
||||||
.AddEnvironmentVariables();
|
.AddJsonFile("config.json")
|
||||||
|
.AddEnvironmentVariables();
|
||||||
var configuration = builder.Build();
|
var configuration = builder.Build();
|
||||||
|
|
||||||
//const string adminRole = "Administrator";
|
//const string adminRole = "Administrator";
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,11 @@ namespace MusicStore
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// 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
|
// 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.
|
// can be overridden by a different setting while deployed remotely.
|
||||||
var builder = new ConfigurationBuilder(applicationEnvironment.ApplicationBasePath)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(applicationEnvironment.ApplicationBasePath)
|
||||||
//All environment variables in the process's context flow in as configuration values.
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables();
|
//All environment variables in the process's context flow in as configuration values.
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
_platform = new Platform(runtimeEnvironment);
|
_platform = new Platform(runtimeEnvironment);
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,11 @@ namespace MusicStore
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// 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
|
// 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.
|
// can be overridden by a different setting while deployed remotely.
|
||||||
var builder = new ConfigurationBuilder(applicationEnvironment.ApplicationBasePath)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(applicationEnvironment.ApplicationBasePath)
|
||||||
//All environment variables in the process's context flow in as configuration values.
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables();
|
//All environment variables in the process's context flow in as configuration values.
|
||||||
|
.AddEnvironmentVariables();
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,11 @@ namespace MusicStore
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// 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
|
// 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.
|
// be overridden by a different setting while deployed remotely.
|
||||||
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(env.ApplicationBasePath)
|
||||||
//All environment variables in the process's context flow in as configuration values.
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables();
|
//All environment variables in the process's context flow in as configuration values.
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
_platform = new Platform(runtimeEnvironment);
|
_platform = new Platform(runtimeEnvironment);
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
//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)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(env.ApplicationBasePath)
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddJsonFile("config.json")
|
||||||
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
_runtimeEnvironment = runtimeEnvironment;
|
_runtimeEnvironment = runtimeEnvironment;
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
//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)
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("config.json")
|
.SetBasePath(appEnvironment.ApplicationBasePath)
|
||||||
.AddEnvironmentVariables() //All environment variables in the process's context flow in as configuration values.
|
.AddJsonFile("config.json")
|
||||||
.AddJsonFile("configoverride.json", optional: true); // Used to override some configuration parameters that cannot be overridden by environment.
|
.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();
|
Configuration = builder.Build();
|
||||||
_runtimeEnvironment = runtimeEnvironment;
|
_runtimeEnvironment = runtimeEnvironment;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue