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

@@ -0,0 +1,26 @@
using System;
using System.Xml;
using System.Xml.Linq;
namespace Umbraco.Core.Models
{
public static class PropertyExtensions
{
/// <summary>
/// Creates the xml representation for the <see cref="Property"/> object
/// </summary>
/// <param name="property"><see cref="Property"/> to generate xml for</param>
/// <returns>Xml of the property and its value</returns>
public static XElement ToXml(this Property property)
{
string nodeName = property.Alias.ToUmbracoAlias();
var xd = new XmlDocument();
XmlNode xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, "");
xmlNode.AppendChild(property.PropertyType.DataType(property.Id).Data.ToXMl(xd));
var element = xmlNode.GetXElement();
return element;
}
}
}