public bool Delete(ConfigInfo config) { XmlElement oldChild = this.getElement(config.Key); if (oldChild != null) { this.getXmlNode().RemoveChild(oldChild); this.xDoc.Save(this._fileName); return true; } return false; }
public IList<ConfigInfo> GetList() { XmlNodeList list = this.getXmlNodeList(); IList<ConfigInfo> list2 = new List<ConfigInfo>(); foreach (XmlNode node in list) { ConfigInfo info = new ConfigInfo(); info.Key = node.Attributes["key"].Value; info.Name = node.Attributes["name"].Value; info.Value = node.Attributes["value"].Value; info.Desc = node.Attributes["desc"].Value; list2.Add(info); } return list2; }
public bool SetValue(ConfigInfo config, bool bCreate) { bool flag = true; try { XmlElement newChild = this.getElement(config.Key); if (newChild != null) { newChild.SetAttribute("value", config.Value); newChild.SetAttribute("name", config.Name); newChild.SetAttribute("desc", config.Desc); this.xDoc.Save(this._fileName); return flag; } if (bCreate) { XmlNode node = this.getXmlNode(); newChild = this.xDoc.CreateElement("add"); newChild.SetAttribute("key", config.Key); newChild.SetAttribute("value", config.Value); newChild.SetAttribute("name", config.Name); newChild.SetAttribute("desc", config.Desc); node.AppendChild(newChild); this.xDoc.Save(this._fileName); } } catch { flag = false; } return flag; }
public bool Update(ConfigInfo config) { return (((config != null) && !string.IsNullOrEmpty(config.Key)) && this.SetValue(config, false)); }
public bool Insert(ConfigInfo config) { return ((((config != null) && !string.IsNullOrEmpty(config.Key)) && !this.Exist(config.Key)) && this.SetValue(config, true)); }