New dashboard config classes all tested

This commit is contained in:
Shannon
2013-10-03 17:50:42 +10:00
parent e2f9b1c7d9
commit b9257fceeb
6 changed files with 136 additions and 14 deletions

View File

@@ -1,10 +1,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Umbraco.Core.Configuration.Dashboard
{
internal class AccessElement : RawXmlConfigurationElement, IAccess
{
public AccessElement()
{
}
public AccessElement(XElement rawXml)
:base(rawXml)
{
}
public IEnumerable<IAccessItem> Rules
{
get

View File

@@ -1,33 +1,54 @@
using System.Configuration;
using System;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
namespace Umbraco.Core.Configuration.Dashboard
{
internal class ControlElement : RawXmlConfigurationElement, IControl
{
[ConfigurationProperty("showOnce", DefaultValue = false)]
public bool ShowOnce
{
get { return (bool)this["showOnce"]; }
get
{
return RawXml.Attribute("showOnce") == null
? false
: bool.Parse(RawXml.Attribute("showOnce").Value);
}
}
[ConfigurationProperty("addPanel", DefaultValue = true)]
public bool AddPanel
{
get { return (bool)this["addPanel"]; }
get
{
return RawXml.Attribute("addPanel") == null
? true
: bool.Parse(RawXml.Attribute("addPanel").Value);
}
}
[ConfigurationProperty("panelCaption", DefaultValue = "")]
public string PanelCaption
{
get { return (string)this["panelCaption"]; }
get
{
return RawXml.Attribute("panelCaption") == null
? ""
: RawXml.Attribute("panelCaption").Value;
}
}
[ConfigurationProperty("access")]
public AccessElement Access
{
get { return (AccessElement)this["access"]; }
get
{
var access = RawXml.Element("access");
if (access == null)
{
return new AccessElement();
}
return new AccessElement(access);
}
}
public string ControlPath
@@ -40,8 +61,14 @@ namespace Umbraco.Core.Configuration.Dashboard
{
throw new ConfigurationErrorsException("The control element must contain a text node indicating the control path");
}
return txt.Value;
return txt.Value.Trim();
}
}
IAccess IControl.AccessRights
{
get { return Access; }
}
}
}

View File

@@ -9,5 +9,7 @@
string PanelCaption { get; }
string ControlPath { get; }
IAccess AccessRights { get; }
}
}

View File

@@ -25,8 +25,8 @@ namespace Umbraco.Core.Configuration
//now validate and set the raw value
if (RawXml.HasElements)
throw new InvalidOperationException("An InnerTextConfigurationElement cannot contain any child elements, only attributes and a value");
RawValue = RawXml.Value;
RawValue = RawXml.Value.Trim();
//RawValue = reader.ReadElementContentAsString();
}