Adds SerializationHelper to userControlWrapper (makes it super easy to do xml properties with uc wrapper)
This commit is contained in:
@@ -349,6 +349,7 @@
|
|||||||
<Compile Include="tinymce\TinyMCELegacyControl.cs" />
|
<Compile Include="tinymce\TinyMCELegacyControl.cs" />
|
||||||
<Compile Include="tinymce\tinyMCEImageHelper.cs" />
|
<Compile Include="tinymce\tinyMCEImageHelper.cs" />
|
||||||
<Compile Include="tinymce\tinyMCEPreValueConfigurator.cs" />
|
<Compile Include="tinymce\tinyMCEPreValueConfigurator.cs" />
|
||||||
|
<Compile Include="userControlWrapper\SerializationHelper.cs" />
|
||||||
<Compile Include="userControlWrapper\usercontrolData.cs" />
|
<Compile Include="userControlWrapper\usercontrolData.cs" />
|
||||||
<Compile Include="wysiwyg\editorButton.cs" />
|
<Compile Include="wysiwyg\editorButton.cs" />
|
||||||
<Compile Include="tinyMCE3\TinyMCE.cs" />
|
<Compile Include="tinyMCE3\TinyMCE.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace umbraco.editorControls.userControlWrapper
|
||||||
|
{
|
||||||
|
public class SerializationHelper
|
||||||
|
{
|
||||||
|
public static object ValueFromXmlString(object value, Type type)
|
||||||
|
{
|
||||||
|
XmlSerializer ser = new XmlSerializer(value.GetType());
|
||||||
|
StringReader strRdr = new StringReader(value.ToString());
|
||||||
|
XmlTextReader xmlRdr = new XmlTextReader(strRdr);
|
||||||
|
object obj = ser.Deserialize(xmlRdr);
|
||||||
|
xmlRdr.Close();
|
||||||
|
strRdr.Close();
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ValueToXmlString(object value)
|
||||||
|
{
|
||||||
|
MemoryStream str = new MemoryStream();
|
||||||
|
XmlSerializer ser = new XmlSerializer(value.GetType());
|
||||||
|
ser.Serialize(str, value);
|
||||||
|
str.Seek(0, System.IO.SeekOrigin.Begin);
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.Load(str);
|
||||||
|
str.Close();
|
||||||
|
return doc.InnerXml;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user