React to aspnet/Configuration #194
This commit is contained in:
parent
c428ddffa3
commit
54ddefe88c
|
|
@ -15,9 +15,10 @@ namespace MusicStore.Spa
|
||||||
{
|
{
|
||||||
public Startup(IApplicationEnvironment env)
|
public Startup(IApplicationEnvironment env)
|
||||||
{
|
{
|
||||||
Configuration = new ConfigurationSection(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
||||||
.AddJsonFile("Config.json")
|
.AddJsonFile("Config.json")
|
||||||
.AddEnvironmentVariables();
|
.AddEnvironmentVariables();
|
||||||
|
Configuration = builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Microsoft.Framework.Configuration.IConfiguration Configuration { get; set; }
|
public Microsoft.Framework.Configuration.IConfiguration Configuration { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -89,9 +89,10 @@ namespace MusicStore.Models
|
||||||
{
|
{
|
||||||
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
|
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
|
||||||
|
|
||||||
var configuration = new ConfigurationSection(appEnv.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables();
|
.AddEnvironmentVariables();
|
||||||
|
var configuration = builder.Build();
|
||||||
|
|
||||||
//const string adminRole = "Administrator";
|
//const string adminRole = "Administrator";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,9 @@ namespace MusicStore
|
||||||
public Task<int> Main(string[] args)
|
public Task<int> Main(string[] args)
|
||||||
{
|
{
|
||||||
//Add command line configuration source to read command line parameters.
|
//Add command line configuration source to read command line parameters.
|
||||||
var config = new ConfigurationSection();
|
var builder = new ConfigurationBuilder();
|
||||||
config.AddCommandLine(args);
|
builder.AddCommandLine(args);
|
||||||
|
var config = builder.Build();
|
||||||
|
|
||||||
using (new WebHostBuilder(_serviceProvider, config)
|
using (new WebHostBuilder(_serviceProvider, config)
|
||||||
.UseServer("Microsoft.AspNet.Server.WebListener")
|
.UseServer("Microsoft.AspNet.Server.WebListener")
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
||||||
Configuration = new ConfigurationSection(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
|
||||||
|
Configuration = builder.Build();
|
||||||
_platform = new Platform(runtimeEnvironment);
|
_platform = new Platform(runtimeEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
||||||
Configuration = new ConfigurationSection(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
Configuration = builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; private set; }
|
public IConfiguration Configuration { get; private set; }
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
||||||
Configuration = new ConfigurationSection(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
|
||||||
|
Configuration = builder.Build();
|
||||||
_platform = new Platform(runtimeEnvironment);
|
_platform = new Platform(runtimeEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
||||||
Configuration = new ConfigurationSection(env.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(env.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
|
||||||
|
Configuration = builder.Build();
|
||||||
_runtimeEnvironment = runtimeEnvironment;
|
_runtimeEnvironment = runtimeEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,
|
//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.
|
||||||
Configuration = new ConfigurationSection(appEnvironment.ApplicationBasePath)
|
var builder = new ConfigurationBuilder(appEnvironment.ApplicationBasePath)
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables() //All environment variables in the process's context flow in as configuration values.
|
.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.
|
.AddJsonFile("configoverride.json", optional: true); // Used to override some configuration parameters that cannot be overridden by environment.
|
||||||
|
|
||||||
|
Configuration = builder.Build();
|
||||||
_runtimeEnvironment = runtimeEnvironment;
|
_runtimeEnvironment = runtimeEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue