public void Read(string fileName)
{
var doc = new XmlDocument();
try
{
doc.Load(fileName);
}
catch (IOException)
{
// If the file does not exist, then simply initialize to all
// the default values.
InitializeDefaults(new List<string>());
return;
}
var root = doc.ChildNodes[1] as XmlElement;
List<string> seen = new List<string>();
foreach (var child in root.ChildNodes)
{
var element = child as XmlElement;
if (element == null)
continue;
var name = element.Name;
// If we don't have a record for this option, just ignore it.
if (!OptionRecords.ContainsKey(name))
continue;
var record = OptionRecords[name];
var obj = record.GetValueOrDefault(element);
Set(name, obj);
seen.Add(name);
}
InitializeDefaults(seen);
}