Serialization

  • Thread starter Thread starter Joe Audette
  • Start date Start date
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.
 
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
 
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
 
Back
Top