Skip to main content

Microsoft Silverlight

Answered Question Xml serialize in Sl2RSS Feed

(0)

xsdf
xsdf

Member

Member

148 points

224 Posts

Xml serialize in Sl2

Does sl 2 support use xml serializer to serialize the custom type like used in winform ? 

************************************
To be or not to be, it's not a question ,it's life.

lingbing
lingbing

Contributor

Contributor

2249 points

406 Posts

Re: Xml serialize in Sl2

The answer is yes.

Ling Bing
Bei Jing University of Aeronautics and Astronautics
Bei Jing, China

xsdf
xsdf

Member

Member

148 points

224 Posts

Re: Xml serialize in Sl2

 Could you please give me more in detail ?

What I need is just Use Xml Serialization to save a Custom Type to the IsolatedStroage . 

 

************************************
To be or not to be, it's not a question ,it's life.

lingbing
lingbing

Contributor

Contributor

2249 points

406 Posts

Answered Question

Re: Xml serialize in Sl2

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!

Ling Bing
Bei Jing University of Aeronautics and Astronautics
Bei Jing, China

xsdf
xsdf

Member

Member

148 points

224 Posts

Re: Xml serialize in Sl2

 Thanks.

************************************
To be or not to be, it's not a question ,it's life.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities