Is it possible to implement IXmlSerializable and in my XML file capture an object of type Dictionary> ?
I have the following
public class coolio : IXmlSerializable
{
private int a;
private bool b;
private string c;
private Dictionary<string, List<string>> coco;
public coolio(int _a, bool _b, string _c, Dictionary<string, List<string>> _coco)
{
a=_a;
b=_b;
c=_c;
coco=_coco;
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void WriteXml(XmlWriter writer)
{
const string myType = "coolio";
writer.WriteStartElement(myType);
writer.WriteAttributeString("a", a.ToString());
writer.WriteAttributeString("b", b.ToString());
writer.WriteAttributeString("c", c);
// How do I add a subelement for Dictionary<string, List<string>> coco?
writer.WriteEndElement();
}
public void ReadXml(XmlReader reader)
{
if (reader.MoveToContent() != XmlNodeType.Element || reader.LocalName != "coolio")
return;
a= int.Parse(reader["a"]);
b = bool.Parse(reader["b"]);
c= reader["c"];
// How do I read subelement into Dictionary<string, List<string>> coco?
}
}
But I am stumped as to how I could add the Dictionary> (XML seriliazed to my XML file)