예제 #1
0
        public void AddSetting(XmlSettingsItem value)
        {
            if (this.Items == null)
            {
                this.Items = new Dictionary <string, XmlSettingsItem>();
            }

            if (this.Items.ContainsKey(value.Key))
            {
                this.Items.Remove(value.Key);
            }

            this.Items.Add(value.Key, value);
        }
예제 #2
0
        public string GetString(string key, string defaultValue)
        {
            if (this.Values == null)
            {
                return(defaultValue);
            }
            else if (!this.Values.ContainsKey(key))
            {
                return(defaultValue);
            }

            XmlSettingsItem item = this.Values[key] as XmlSettingsItem;

            return(item != null ? item.Value : defaultValue);
        }
예제 #3
0
        public XmlSettingsItem(XmlElement node)
        {
            XmlSettingsItem subitem;

            this.Key   = node.GetAttribute("key");
            this.Value = node.GetAttribute("value");

            if (node.SelectNodes("Value").Count > 0)
            {
                this.Items = new Dictionary <string, XmlSettingsItem>();
                foreach (XmlNode xnode in node.SelectNodes("Value"))
                {
                    subitem = new XmlSettingsItem((XmlElement)xnode);
                    this.Items.Add(subitem.Key, subitem);
                }
            }
        }
예제 #4
0
        public void AddSetting(string key, bool value)
        {
            XmlSettingsItem item = new XmlSettingsItem(key, value ? "1" : "0");

            AddSetting(item);
        }
예제 #5
0
        public void AddSetting(string key, long value)
        {
            XmlSettingsItem item = new XmlSettingsItem(key, value.ToString());

            AddSetting(item);
        }