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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user