2013-10-21 18:36:46 +11:00
using System ;
using System.Xml ;
2013-10-03 12:45:40 +10:00
using Umbraco.Core ;
2012-04-28 13:35:16 -01:00
using umbraco.cms.businesslogic.datatype ;
2012-04-29 19:05:59 -01:00
namespace umbraco.editorControls
2012-04-28 13:35:16 -01:00
{
/// <summary>
/// Overrides the <see cref="umbraco.cms.businesslogic.datatype.DefaultData"/> object to return the value as XML.
/// </summary>
2013-10-21 18:36:46 +11:00
[Obsolete("IDataType and all other references to the legacy property editors are no longer used this will be removed from the codebase in future versions")]
2012-04-29 19:05:59 -01:00
public class XmlData : umbraco . cms . businesslogic . datatype . DefaultData
2012-04-28 13:35:16 -01:00
{
/// <summary>
/// Initializes a new instance of the <see cref="XmlData"/> class.
/// </summary>
/// <param name="dataType">Type of the data.</param>
2012-04-29 19:05:59 -01:00
public XmlData ( umbraco . cms . businesslogic . datatype . BaseDataType dataType )
2012-04-28 13:35:16 -01:00
: base ( dataType )
{
}
/// <summary>
/// Converts the data value to XML.
/// </summary>
/// <param name="data">The data to convert to XML.</param>
/// <returns></returns>
public override XmlNode ToXMl ( XmlDocument data )
{
// check that the value isn't null and starts with an opening angle-bracket.
2013-10-03 12:45:40 +10:00
if ( this . Value ! = null & & XmlHelper . CouldItBeXml ( this . Value . ToString ( ) ) )
2012-04-28 13:35:16 -01:00
{
// load the value into an XML document.
var xd = new XmlDocument ( ) ;
xd . LoadXml ( this . Value . ToString ( ) ) ;
// return the XML node.
return data . ImportNode ( xd . DocumentElement , true ) ;
}
else
{
// otherwise render the value as default (in CDATA)
return base . ToXMl ( data ) ;
}
}
}
}