Tuesday, May 11, 2010

Serialization With Silverlight

Say you want to serialize an object using silverlight, well you can't use the binaryformater() like in windows forms development, so what to do.  Silverlight has a the DataContractSerializer class which "Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract."  So this means that you are passing XML string data.

From the windows help: "Use the DataContractSerializer class to serialize and deserialize instances of a type into an XML stream or document. For example, you can create a type named Person with properties that contain essential data, such as a name and address. You can then create and manipulate an instance of the Person class and write all of its property values in an XML document for later retrieval, or in an XML stream for immediate transport."


Here is my code:
Enjoy