React to configuration model change

This commit is contained in:
Troy Dai 2015-04-10 11:42:23 -07:00
parent 25a68f9f79
commit dcac97fe3b
7 changed files with 20 additions and 13 deletions

View File

@ -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();
}

View File

@ -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
/// <returns></returns>
private static async Task CreateAdminUser(IServiceProvider serviceProvider)
{
var configuration = new Configuration()
var appEnv = serviceProvider.GetService<IApplicationEnvironment>();
var configuration = new Configuration(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables();

View File

@ -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.
}

View File

@ -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
/// </summary>
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.
}

View File

@ -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
/// </summary>
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.
}

View File

@ -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.
}

View File

@ -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.