NEW!
CSHTML5 has now become OpenSilver!
We are happy to announce that CSHTML5 has been significantly improved and rebranded
to 'OpenSilver', which stands for 'Open-source reimplementation of Silverlight'. It is fully backward compatible and it can be downloaded from
OpenSilver.net. Upgrading from
CSHTML5 to OpenSilver is very easy.
Read the FAQ
UPDATE: Starting in Beta 13 and above, we recommend you to use the new DataContractSerializer instead of the XmlSerializer.
Please use the following code to serialize an object with the XmlSerializer:
var serializer = new XmlSerializer(typeof(ClassToSerialize));
var stream = new MemoryStream();
serializer.Serialize(stream, _classToSerialize);
stream.Seek(0, SeekOrigin.Begin);
var reader = new StreamReader(stream);
var serializedXml = reader.ReadToEnd();
Please use the following code to deserialize an object with the XmlSerializer:
var deserializer = new XmlSerializer(typeof(ClassToSerialize));
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(serializedXml));
var xmlReader = XmlReader.Create(memoryStream);
ClassToSerialize deserializedObject = (ClassToSerialize)deserializer.Deserialize(xmlReader);
Example of serializable class:
[DataContract]
public class ClassToSerialize
{
public string TextField { get; set; }
public DateTime DateField { get; set; }
public Guid GuidField { get; set; }
public bool BooleanField { get; set; }
}
For any question, please post a message on the forums or contact us.