Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Xml serialize in Sl2
4 replies. Latest Post by xsdf on August 28, 2008.
(0)
xsdf
Member
148 points
224 Posts
08-27-2008 10:07 PM |
Does sl 2 support use xml serializer to serialize the custom type like used in winform ?
lingbing
Contributor
2249 points
406 Posts
08-27-2008 10:28 PM |
The answer is yes.
08-27-2008 10:51 PM |
Could you please give me more in detail ?
What I need is just Use Xml Serialization to save a Custom Type to the IsolatedStroage .
08-27-2008 11:13 PM |
If you just want to save a custom type to the IsolatedStroage, I think Xml Serialization is not necessary.
In the class System.IO.IsolatedStorage.IsolatedStorageSettings, you can use it to save your type. Simply, just use the singleton IsolatedStorageSettings.ApplicationSettings to do that by using the method Add(string key, object value), and after that, call Save() method, and then your custom type object will be saved. When you want to load your object, you can simply use ApplicattionSettings[string key] to get your object and change it to your type by "as".
By the way, the Save() method use DataContractSerializer to serialize your object and write it to a stream and save it. I think what you wants is this, and Microsoft has done it for everybody, just use it, everything is ok.
Regards!
08-28-2008 1:54 AM |
Thanks.