From 36d82dc43bc2bfea1f5922419e1168bec0980b8e Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 13 Sep 2013 14:06:36 +1000 Subject: [PATCH] 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. --- src/Umbraco.Core/ApplicationContext.cs | 23 ++++++++++++- .../Configuration/UmbracoConfiguration.cs | 19 +++++++++++ .../UmbracoSettings/IUmbracoSettings.cs | 33 +++++++++++++++++++ .../UmbracoSettings/UmbracoSettingsSection.cs | 31 ----------------- src/Umbraco.Core/Umbraco.Core.csproj | 2 ++ src/Umbraco.Web.UI/web.Template.Debug.config | 15 +++++++-- src/Umbraco.Web.UI/web.Template.config | 9 ++++- 7 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 src/Umbraco.Core/Configuration/UmbracoConfiguration.cs create mode 100644 src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettings.cs diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index ee9ba7c1a3..0aa861a87d 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -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 } } - /// + 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; + } + } + + /// /// The original/first url that the web application executes /// /// diff --git a/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs b/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs new file mode 100644 index 0000000000..0116ffa394 --- /dev/null +++ b/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs @@ -0,0 +1,19 @@ +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Core.Configuration +{ + /// + /// The gateway to all umbraco configuration + /// + public class UmbracoConfiguration + { + //TODO: Add other configurations here ! + + public IUmbracoSettings UmbracoSettings { get; private set; } + + public UmbracoConfiguration(IUmbracoSettings umbracoSettings) + { + UmbracoSettings = umbracoSettings; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettings.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettings.cs new file mode 100644 index 0000000000..8feb67172d --- /dev/null +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettings.cs @@ -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; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs index b1a35e97b7..65d8994f21 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs @@ -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 { diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8a7bce6897..3706e511f7 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -150,6 +150,7 @@ + @@ -202,6 +203,7 @@ + diff --git a/src/Umbraco.Web.UI/web.Template.Debug.config b/src/Umbraco.Web.UI/web.Template.Debug.config index 758d07c6cb..8d898065ef 100644 --- a/src/Umbraco.Web.UI/web.Template.Debug.config +++ b/src/Umbraco.Web.UI/web.Template.Debug.config @@ -19,9 +19,20 @@
-
+
+ + + +
+ + - + + + + + + diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 0913f39cd9..e454acc61c 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -15,8 +15,16 @@
+ +
+ + + + + + @@ -31,7 +39,6 @@ Umbraco web.config configuration documentation can be found here: http://our.umbraco.org/documentation/using-umbraco/config-files/#webconfig --> -