So was playing about with Binary serialization, and think I have a nice base class you might want to use if you ever want serialize your classes. This is the base class
Not a great deal in there other than it has to have the Serializable class attribute and implement the ISerializable interface and uses a generic in it’s definition, there are two constructors, the second needed for de-serialization. We then have Serialize and Deserialize statics, both methods do exactly what they say and then finally we implement the ISerializable method GetObjectData.
So pretty simple stuff, this is how you can then derive from this to then use all the lovely serialization stuff in the base class
As you can see a pretty simple class, has 4 properties and a couple of constructors, but as we have derived from SerializableBase class we get all the serializable goodness, so this is how you could implement it
The great thing about this is that you can go and add as many properties as you like and you wont have to change any of the serialization code as it will automatically pick up the new properties :)
Just altered the base class so it’s now WP7 friendly, I guess you could go 100% with the DataContractSerializer though…