Created umbraco config holder object which is exposed on the application context, updated the web.config with the new section and the transform to ensure it get's added.

This commit is contained in:
Shannon
2013-09-13 14:06:36 +10:00
parent e16e2917c9
commit 36d82dc43b
7 changed files with 97 additions and 35 deletions

View File

@@ -5,6 +5,7 @@ using System.Web;
using System.Web.Caching;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Services;
@@ -67,6 +68,7 @@ namespace Umbraco.Core
readonly System.Threading.ManualResetEventSlim _isReadyEvent = new System.Threading.ManualResetEventSlim(false);
private DatabaseContext _databaseContext;
private ServiceContext _services;
private UmbracoConfiguration _umbracoConfiguration;
public bool IsReady
{
@@ -105,7 +107,26 @@ namespace Umbraco.Core
}
}
/// <summary>
public UmbracoConfiguration UmbracoConfiguration
{
get
{
if (_umbracoConfiguration == null)
{
var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettings;
if (umbracoSettings == null)
{
throw new InvalidOperationException("Could not find configuration section 'umbracoConfiguration/settings' or it does not cast to " + typeof (IUmbracoSettings));
}
//create a new one if it is null
_umbracoConfiguration = new UmbracoConfiguration(umbracoSettings);
}
return _umbracoConfiguration;
}
}
/// <summary>
/// The original/first url that the web application executes
/// </summary>
/// <remarks>

View File

@@ -0,0 +1,19 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Configuration
{
/// <summary>
/// The gateway to all umbraco configuration
/// </summary>
public class UmbracoConfiguration
{
//TODO: Add other configurations here !
public IUmbracoSettings UmbracoSettings { get; private set; }
public UmbracoConfiguration(IUmbracoSettings umbracoSettings)
{
UmbracoSettings = umbracoSettings;
}
}
}

View File

@@ -0,0 +1,33 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IUmbracoSettings
{
IContent Content { get; }
ISecurity Security { get; }
IRequestHandler RequestHandler { get; }
ITemplates Templates { get; }
IDeveloper Developer { get; }
IViewstateMoverModule ViewstateMoverModule { get; }
ILogging Logging { get; }
IScheduledTasks ScheduledTasks { get; }
IDistributedCall DistributedCall { get; }
IRepositories PackageRepositories { get; }
IProviders Providers { get; }
IHelp Help { get; }
IWebRouting WebRouting { get; }
IScripting Scripting { get; }
}
}

View File

@@ -3,37 +3,6 @@ using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IUmbracoSettings
{
IContent Content { get; }
ISecurity Security { get; }
IRequestHandler RequestHandler { get; }
ITemplates Templates { get; }
IDeveloper Developer { get; }
IViewstateMoverModule ViewstateMoverModule { get; }
ILogging Logging { get; }
IScheduledTasks ScheduledTasks { get; }
IDistributedCall DistributedCall { get; }
IRepositories PackageRepositories { get; }
IProviders Providers { get; }
IHelp Help { get; }
IWebRouting WebRouting { get; }
IScripting Scripting { get; }
}
public class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettings
{

View File

@@ -150,6 +150,7 @@
<Compile Include="Configuration\FileSystemProviderElement.cs" />
<Compile Include="Configuration\FileSystemProviderElementCollection.cs" />
<Compile Include="Configuration\FileSystemProvidersSection.cs" />
<Compile Include="Configuration\UmbracoConfiguration.cs" />
<Compile Include="Configuration\UmbracoConfigurationSection.cs" />
<Compile Include="Configuration\UmbracoSettings\AppCodeFileExtensionsCollection.cs" />
<Compile Include="Configuration\UmbracoSettings\AppCodeFileExtensionsElement.cs" />
@@ -202,6 +203,7 @@
<Compile Include="Configuration\UmbracoSettings\ISecurity.cs" />
<Compile Include="Configuration\UmbracoSettings\IServerElement.cs" />
<Compile Include="Configuration\UmbracoSettings\ITemplates.cs" />
<Compile Include="Configuration\UmbracoSettings\IUmbracoSettings.cs" />
<Compile Include="Configuration\UmbracoSettings\IUrlReplacing.cs" />
<Compile Include="Configuration\UmbracoSettings\IUserProvider.cs" />
<Compile Include="Configuration\UmbracoSettings\IViewstateMoverModule.cs" />

View File

@@ -19,9 +19,20 @@
<configSections>
<section name="Examine" type="Examine.Config.ExamineSettings, Examine" xdt:Locator="Match(name)" xdt:Transform="SetAttributes(type)"/>
<section name="ExamineLuceneIndexSets" type="Examine.LuceneEngine.Config.IndexSets, Examine" xdt:Locator="Match(name)" xdt:Transform="SetAttributes(type)"/>
<section name="ExamineLuceneIndexSets" type="Examine.LuceneEngine.Config.IndexSets, Examine" xdt:Locator="Match(name)" xdt:Transform="SetAttributes(type)"/>
<sectionGroup name="umbracoConfiguration" xdt:Locator="Match(name)" xdt:Transform="Remove" />
<sectionGroup name="umbracoConfiguration" xdt:Transform="Insert">
<section name="settings" type="Umbraco.Core.Configuration.UmbracoSettings.UmbracoSettingsSection, Umbraco.Core" requirePermission="false" />
</sectionGroup>
</configSections>
<umbracoConfiguration xdt:Transform="Remove"/>
<umbracoConfiguration xdt:Transform="InsertBefore(/configuration/appSettings)">
<settings configSource="config\umbracoSettings.config" />
</umbracoConfiguration>
<appSettings>
<add key="umbracoDbDSN" xdt:Transform="Remove" xdt:Locator="Match(key)" />
</appSettings>

View File

@@ -15,8 +15,16 @@
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
<sectionGroup name="umbracoConfiguration">
<section name="settings" type="Umbraco.Core.Configuration.UmbracoSettings.UmbracoSettingsSection, Umbraco.Core" requirePermission="false" />
</sectionGroup>
</configSections>
<umbracoConfiguration>
<settings configSource="config\umbracoSettings.config" />
</umbracoConfiguration>
<urlrewritingnet configSource="config\UrlRewriting.config" />
<microsoft.scripting configSource="config\scripting.config" />
<clientDependency configSource="config\ClientDependency.config" />
@@ -31,7 +39,6 @@
Umbraco web.config configuration documentation can be found here:
http://our.umbraco.org/documentation/using-umbraco/config-files/#webconfig
-->
<add key="umbracoDbDSN" value="" />
<add key="umbracoConfigurationStatus" value="" />
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />