public void AddSettings(SettingsEntry settings) { if (_entries.Where(e => e.Key == settings.Key).Count() > 0) throw new ApplicationException("An attempt was made to add multiple settings with the same key."); _entries.Add(settings); }
public void ReadXml(XmlReader reader) { XPathDocument xPath = new XPathDocument(reader); XPathNavigator navigator = xPath.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("//SettingsEntries/Setting"); while (iterator.MoveNext()) { SettingsEntry entry = new SettingsEntry(); entry.Key = iterator.Current.GetAttribute("key", String.Empty); String typeName = iterator.Current.GetAttribute("type", String.Empty); Type type = Type.GetType(typeName); XmlSerializer xs = new XmlSerializer(type); iterator.Current.MoveToFirstChild(); entry.Settings = (ISettings)xs.Deserialize(iterator.Current.ReadSubtree()); _entries.Add(entry); } }