public static DatabaseConfiguration Read(string file)
{
DatabaseConfiguration config = new DatabaseConfiguration ();
StreamReader s = new StreamReader (file);
using (s) {
XmlTextReader tr = new XmlTextReader (s);
tr.MoveToContent ();
if (tr.IsEmptyElement)
return config;
tr.ReadStartElement ("Configuration");
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
tr.Skip ();
}
else if (tr.LocalName == "DisabledAddins") {
// For back compatibility
tr.ReadStartElement ();
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
config.addinStatus [tr.ReadElementString ()] = null;
else
tr.Skip ();
tr.MoveToContent ();
}
tr.ReadEndElement ();
}
else if (tr.LocalName == "AddinStatus") {
tr.ReadStartElement ();
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
string aid = tr.GetAttribute ("id");
string senabled = tr.GetAttribute ("enabled");
if (senabled.Length == 0 || senabled == "True")
config.addinStatus [aid] = config;
else
config.addinStatus [aid] = null;
}
tr.Skip ();
tr.MoveToContent ();
}
tr.ReadEndElement ();
}
tr.MoveToContent ();
}
}
return config;
}