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:
26
src/Umbraco.Core/Models/PropertyExtensions.cs
Normal file
26
src/Umbraco.Core/Models/PropertyExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user