Moving interfaces for services to Umbraco.Core.

Adding xml extensions for Content to generate xml for the xml cache.
Adding test for xml generation.
This commit is contained in:
sitereactor
2012-11-06 10:47:14 -01:00
parent f438ad16e0
commit ec9880968f
37 changed files with 247 additions and 97 deletions

View File

@@ -1,15 +1,14 @@
using System;
using System.Xml;
using System.Xml.Linq;
namespace Umbraco.Core
{
/// <summary>
/// Extension methods for xml objects
/// </summary>
internal static class XmlExtensions
{
public static T AttributeValue<T>(this XmlNode xml, string attributeName)
{
if (xml == null) throw new ArgumentNullException("xml");
@@ -26,5 +25,22 @@ namespace Umbraco.Core
return default(T);
}
public static XElement GetXElement(this XmlNode node)
{
XDocument xDoc = new XDocument();
using (XmlWriter xmlWriter = xDoc.CreateWriter())
node.WriteTo(xmlWriter);
return xDoc.Root;
}
public static XmlNode GetXmlNode(this XElement element)
{
using (XmlReader xmlReader = element.CreateReader())
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
return xmlDoc;
}
}
}
}