G
Guest
I was testing XML Serialization to assess if it fits my needs. I coded two
methods, one dumping the XML serialized object to a file, and the other that
recreates the object:
static Graph Awake(string filename)
{
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Graph));
System.IO.TextReader r = new System.IO.StreamReader(filename);
object res = s.Deserialize(r);
r.Close();
return (Graph) res;
}
static void Hibernate(string filename, Graph graph)
{
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Graph));
System.IO.TextWriter w = new System.IO.StreamWriter(filename, false);
s.Serialize(w, graph);
w.Close();
}
If I run those methods separately, they work fine.
However, if I run Hibernate and then Awake, Awake throws an exception...
Furthermore, if I command Hibernate to dump the XML data to a file other
than the one Awake is going to read from, Awake fails again with the same
error.
Any ideas? Bug?
Regards,
Manuel.
methods, one dumping the XML serialized object to a file, and the other that
recreates the object:
static Graph Awake(string filename)
{
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Graph));
System.IO.TextReader r = new System.IO.StreamReader(filename);
object res = s.Deserialize(r);
r.Close();
return (Graph) res;
}
static void Hibernate(string filename, Graph graph)
{
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Graph));
System.IO.TextWriter w = new System.IO.StreamWriter(filename, false);
s.Serialize(w, graph);
w.Close();
}
If I run those methods separately, they work fine.
However, if I run Hibernate and then Awake, Awake throws an exception...
Furthermore, if I command Hibernate to dump the XML data to a file other
than the one Awake is going to read from, Awake fails again with the same
error.
Any ideas? Bug?
Regards,
Manuel.