Got the dashboard config section classes working with tests, now to add more tests

This commit is contained in:
Shannon
2013-10-03 17:17:53 +10:00
parent 03b1c9e5ee
commit e2f9b1c7d9
4 changed files with 33 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ namespace Umbraco.Core.Configuration.Dashboard
protected override object GetElementKey(ConfigurationElement element)
{
return ((ControlElement)element).Value;
return ((ControlElement)element).ControlPath;
}
IEnumerator<IControl> IEnumerable<IControl>.GetEnumerator()

View File

@@ -1,8 +1,10 @@
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
namespace Umbraco.Core.Configuration.Dashboard
{
internal class ControlElement : InnerTextConfigurationElement<string>, IControl
internal class ControlElement : RawXmlConfigurationElement, IControl
{
[ConfigurationProperty("showOnce", DefaultValue = false)]
public bool ShowOnce
@@ -22,9 +24,24 @@ namespace Umbraco.Core.Configuration.Dashboard
get { return (string)this["panelCaption"]; }
}
[ConfigurationProperty("access")]
public AccessElement Access
{
get { return (AccessElement)this["access"]; }
}
public string ControlPath
{
get { return Value; }
get
{
//we need to return the first (and only) text element of the children (wtf... who designed this configuration ! :P )
var txt = RawXml.Nodes().OfType<XText>().FirstOrDefault();
if (txt == null)
{
throw new ConfigurationErrorsException("The control element must contain a text node indicating the control path");
}
return txt.Value;
}
}
}
}

View File

@@ -9,5 +9,7 @@ namespace Umbraco.Core.Configuration.Dashboard
string Area { get; }
IEnumerable<ITab> Tabs { get; }
IAccess AccessRights { get; }
}
}

View File

@@ -16,6 +16,12 @@ namespace Umbraco.Core.Configuration.Dashboard
{
get { return (AreasElement)this["areas"]; }
}
[ConfigurationProperty("access")]
public AccessElement Access
{
get { return (AccessElement)this["access"]; }
}
[ConfigurationCollection(typeof(SectionCollection), AddItemName = "tab")]
[ConfigurationProperty("", IsDefaultCollection = true)]
@@ -34,5 +40,10 @@ namespace Umbraco.Core.Configuration.Dashboard
{
get { return Area.AreaName; }
}
IAccess ISection.AccessRights
{
get { return Access; }
}
}
}