Skip to content

Commit

Permalink
#3 Updated configuration to support xml format
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Gerbenis committed Sep 14, 2015
1 parent d467a0c commit e1ce734
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ private static void ConfigureDefaultServices(IServiceCollection services)

private static void LoadConfiguration(IServiceCollection services, IConfiguration configuration)
{
services.Configure<DefaultConfigurationSection>(configuration.GetSection("modulesSettings"));
services.Configure<DefaultConfigurationSection>(configuration);
var provider = services.BuildServiceProvider();
var config = provider.GetService<IOptions<DefaultConfigurationSection>>().Options;
config.Database.ConnectionString = configuration[config.Database.ConnectionStringName];
if (config?.Database != null)
{
config.Database.ConnectionString = configuration[config.Database.ConnectionStringName];
}
services.AddInstance<Configuration.IConfiguration>(config);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0"?>

<connectionStrings BetterModulesTests="Server=(local);Database=BetterModulesTests;Integrated Security=SSPI;" />
7 changes: 7 additions & 0 deletions vNext/src/BetterModules.Mvc6.Sandbox/Config/modules.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<modulesSettings webSiteUrl="http://BetterModules.core.tests">
<database
schemaName="dbo"
connectionStringName="BetterModulesTests"
databaseType="MsSql2008" />
</modulesSettings>
12 changes: 5 additions & 7 deletions vNext/src/BetterModules.Mvc6.Sandbox/Config/modules.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"modulesSettings": {
"webSiteUrl": "http://BetterModules.core.tests",
"database": {
"schemaName": "dbo",
"connectionStringName": "BetterModulesTests",
"databaseType": "MsSql2008"
}
"webSiteUrl": "http://BetterModules.core.tests",
"database": {
"schemaName": "dbo",
"connectionStringName": "BetterModulesTests",
"databaseType": "MsSql2008"
}
}
2 changes: 2 additions & 0 deletions vNext/src/BetterModules.Mvc6.Sandbox/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
.AddJsonFile("Config/modules.json")
.AddJsonFile("Config/connectionStrings.json");
//.AddXmlFile("Config/modules.config")
//.AddXmlFile("Config/connectionStrings.config");

if (env.IsDevelopment())
{
Expand Down
5 changes: 0 additions & 5 deletions vNext/src/BetterModules.Mvc6.Sandbox/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"AppSettings": {
"SiteTitle": "BetterModules.Mvc6.Sandbox"
},
"Data": {
"DefaultConnection": {
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet5-BetterModules.Mvc6.Sandbox-b140b676-8027-4d3e-a391-dc91b5e50f82;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
}
7 changes: 4 additions & 3 deletions vNext/src/BetterModules.Mvc6.Sandbox/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
"Microsoft.Framework.Logging": "1.0.0-beta7",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta6",
"BetterModules.Core": "1.0.0-*",
"BetterModules.Sample.Module": "1.0.0-*",
"Microsoft.Framework.Logging.EventLog": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7"
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Xml": "1.0.0-beta7"
},

"commands": {
Expand Down

0 comments on commit e1ce734

Please sign in to comment.