Files
Umbraco-CMS/src/Umbraco.Core/Models/PropertyExtensions.cs
Morten Christensen f5bfb90b64 Manually merging a few changes to the ContentService, ContentFactory, ContentRepository and ContentExtensions to avoid a merge hell when pushing latest to the legacy refactor branch.
Current checkin has a few new failing tests due to recent changes, but a few should be resolved by adding a DataTypesResolver setup in the ContentServiceTests fixture.
2012-12-14 15:19:54 -01:00

28 lines
984 B
C#

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(StringAliasCaseType.CamelCase, true);
var xd = new XmlDocument();
XmlNode xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, "");
//This seems to fail during testing
xmlNode.AppendChild(property.PropertyType.DataType(property.Id).Data.ToXMl(xd));
var element = xmlNode.GetXElement();
return element;
}
}
}