Serialization

J

Joe Audette

Is it possible to(XML) serialize an ArrayList of simple
objects in a desktop app, then store the serialized files
as an embedded resource and then de-serialize them on the
device?

The ArrayList would contain objects for this class:
public class Word
{
public Word()
{}

public string PhraseText = "";
public string FontType = "Normal";
public bool IsLink = false;
public bool IsImage = false;
public string ImageToShow;
public string URL;
public Region ClickRegion;
public int Width = 0;
public int Height = 0;
}


I'm trying to use this code to serialize on the desktop
but I'm getting errors:

XmlSerializer mySerializer = new XmlSerializer(typeof
(ArrayList));

StreamWriter streamWriter = new StreamWriter("C:\\" +
name + ".xml");

mySerializer.Serialize(streamWriter, words);
streamWriter.Close();

Thanks for any advice on this.
 
J

Joe Audette

OK, I figured out how to serialize on the desktop to an
xml file but now I can't figure out how to de-serialize
on the device. There is no System.Xml.Serialization
namespace in the CF. Anyone know a way to do it?

Thanks,

Joe
 
A

Alex Feinman [MVP]

There is no Xml serializer in CF as you correctly point out. You can
deserialize it manually with relatively little effort - it's just that the
code will be specific to that particular data structure
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top