using System; using System.Collections.Generic; using System.Linq; using System.Data.Linq; using System.Text; using System.Xml.Serialization; using System.Collections.Specialized; using System.Xml; using System.Windows.Documents; namespace JamSoft.CALDemo.Modules.SettingsManager { [Serializable] public class PropertiesCollection : IXmlSerializable { private NameValueCollection _properties = new NameValueCollection(); private List<string> _keys = new List<string>(); internal PropertiesCollection() { } public void SetSetting(string key, object value) { if (!_keys.Contains(key)) { _properties.Add(key, value.ToString()); _keys.Add(key); } else { _properties.Set(key, value.ToString()); } } public object GetSettingValue(string key) { return _properties[key]; } public System.Xml.Schema.XmlSchema GetSchema() { return null; } public void ReadXml(XmlReader reader) { _properties = new NameValueCollection(); reader.Read(); while (reader.MoveToNextAttribute()) { _properties.Add(reader.Name, reader.Value); } _keys = _properties.AllKeys.ToList(); } public void WriteXml(XmlWriter writer) { foreach (string key in _properties.Keys) { writer.WriteStartElement("property"); string value = _properties[key]; writer.WriteAttributeString(key, value); writer.WriteEndElement(); } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)