From abe4ec6524b69576a5e6c608ba3a8a0da503fca0 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 18 Mar 2013 15:49:43 -0100 Subject: [PATCH] Core.Configuration - simplify --- .../ConfigurationKeyAttribute.cs | 32 +++++-------------- .../Configuration/ConfigurationKeyType.cs | 28 ---------------- .../Configuration/UmbracoSettings.cs | 19 ++--------- src/Umbraco.Core/Umbraco.Core.csproj | 1 - .../BaseRest/Configuration/BaseRestSection.cs | 2 +- src/Umbraco.Web/Configuration/WebRouting.cs | 2 +- 6 files changed, 12 insertions(+), 72 deletions(-) delete mode 100644 src/Umbraco.Core/Configuration/ConfigurationKeyType.cs diff --git a/src/Umbraco.Core/Configuration/ConfigurationKeyAttribute.cs b/src/Umbraco.Core/Configuration/ConfigurationKeyAttribute.cs index d0804f0443..8f8bc50c3e 100644 --- a/src/Umbraco.Core/Configuration/ConfigurationKeyAttribute.cs +++ b/src/Umbraco.Core/Configuration/ConfigurationKeyAttribute.cs @@ -11,34 +11,18 @@ namespace Umbraco.Core.Configuration [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] internal sealed class ConfigurationKeyAttribute : Attribute { - /// - /// Initializes a new instance of the class with a configuration key. - /// - /// The configurationkey. - /// The default configuration key type is Umbraco. - public ConfigurationKeyAttribute(string configurationKey) - : this(configurationKey, ConfigurationKeyType.Umbraco) - { } - - /// - /// Initializes a new instance of the class with a configuration key and a key type. - /// - /// The configurationkey. - /// The key type. - public ConfigurationKeyAttribute(string configurationKey, ConfigurationKeyType keyType) - { - ConfigurationKey = configurationKey; - KeyType = keyType; - } + /// + /// Initializes a new instance of the class with a configuration key. + /// + /// The configurationkey. + public ConfigurationKeyAttribute(string configurationKey) + { + ConfigurationKey = configurationKey; + } /// /// Gets or sets the configuration key. /// public string ConfigurationKey { get; private set; } - - /// - /// Gets or sets the configuration key type. - /// - public ConfigurationKeyType KeyType { get; private set; } } } diff --git a/src/Umbraco.Core/Configuration/ConfigurationKeyType.cs b/src/Umbraco.Core/Configuration/ConfigurationKeyType.cs deleted file mode 100644 index 53c7472e94..0000000000 --- a/src/Umbraco.Core/Configuration/ConfigurationKeyType.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Umbraco.Core.Configuration -{ - /// - /// Indicates the type of configuration section keys. - /// - internal enum ConfigurationKeyType - { - /// - /// An Umbraco section ie with path "/umbraco/sectionKey". - /// - Umbraco, - - /// - /// An Umbraco plugins section ie with path "/umbraco.plugins/sectionKey". - /// - Plugins, - - /// - /// A raw section ie with path "/sectionKey". - /// - Raw - } -} diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings.cs b/src/Umbraco.Core/Configuration/UmbracoSettings.cs index 738c46efec..3249428311 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings.cs @@ -1483,34 +1483,19 @@ namespace Umbraco.Core.Configuration if (string.IsNullOrWhiteSpace(sectionKey)) throw new InvalidOperationException(string.Format("Type \"{0}\" ConfigurationKeyAttribute value is null or empty.", sectionType.FullName)); - var keyType = attr.KeyType; - var section = GetSection(sectionType, sectionKey, keyType); + var section = GetSection(sectionType, sectionKey); Sections[sectionType] = section; return section as T; } } - private static UmbracoConfigurationSection GetSection(Type sectionType, string key, ConfigurationKeyType keyType) + private static UmbracoConfigurationSection GetSection(Type sectionType, string key) { if (!sectionType.Inherits()) throw new ArgumentException(string.Format( "Type \"{0}\" does not inherit from UmbracoConfigurationSection.", sectionType.FullName), "sectionType"); - switch (keyType) - { - case ConfigurationKeyType.Umbraco: - key = "umbraco/" + key; - break; - case ConfigurationKeyType.Plugins: - key = "umbraco.plugins/" + key; - break; - case ConfigurationKeyType.Raw: - break; - default: - throw new ArgumentOutOfRangeException("keyType", keyType, "Invalid ConfigurationKeyType value."); - } - var section = ConfigurationManager.GetSection(key); if (section != null && section.GetType() != sectionType) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 135632c68a..dffb6ddafd 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -115,7 +115,6 @@ - diff --git a/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs b/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs index 6fd437c5f1..9f0cf6e2ed 100644 --- a/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs +++ b/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs @@ -5,7 +5,7 @@ namespace Umbraco.Web.BaseRest.Configuration { // note: the name should be "BaseRest" but we keep it "BaseRestSection" for compat. reasons. - [ConfigurationKey("BaseRestExtensions", ConfigurationKeyType.Raw)] + [ConfigurationKey("BaseRestExtensions")] internal class BaseRestSection : UmbracoConfigurationSection { private const string KeyEnabled = "enabled"; diff --git a/src/Umbraco.Web/Configuration/WebRouting.cs b/src/Umbraco.Web/Configuration/WebRouting.cs index b6f468e133..1e1beba18f 100644 --- a/src/Umbraco.Web/Configuration/WebRouting.cs +++ b/src/Umbraco.Web/Configuration/WebRouting.cs @@ -7,7 +7,7 @@ namespace Umbraco.Web.Configuration /// /// The Web.Routing settings section. /// - [ConfigurationKey("web.routing", ConfigurationKeyType.Umbraco)] + [ConfigurationKey("umbraco/web.routing")] internal class WebRouting : UmbracoConfigurationSection { private const string KeyTrySkipIisCustomErrors = "trySkipIisCustomErrors";