/// <summary> /// ConfigCategories call WriteCategoryData() to persist /// their configuration settings. This overloading is used /// when there is only one top-level XmlElement whose name /// is the name of the category. /// </summary> public void WriteCategoryData(ConfigCategory category) { try { Monitor.Enter(this); XmlElement node = xmlDom.CreateElement("", category.GetName(), ""); category.WriteCategoryData(node); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); if (list.Count == 0) { xmlRoot.AppendChild(node); } else { if (list.Count > 1) { for (int i = 1; i < list.Count; i++) { xmlRoot.RemoveChild(list[i]); } } xmlRoot.ReplaceChild(node, list[0]); } WriteConfigFile(); } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call WriteCategoryData() to persist /// their configuration settings. This overloading is used /// when there is more than one top-level XmlElement whose /// name is the name of the category. In that case, the /// one persisted is has a subelement whose name is /// subElementName and whose value is subElementValue. /// </summary> public void WriteCategoryData(ConfigCategory category, string subElementName, string subElementValue) { try { Monitor.Enter(this); XmlElement node = xmlDom.CreateElement("", category.GetName(), ""); category.WriteCategoryData(node); XmlElement oldNode = GetElementWithSubElementOfNameAndValue(category.GetName(), subElementName, subElementValue); if (oldNode != null) { xmlRoot.ReplaceChild(node, oldNode); } else { xmlRoot.AppendChild(node); } WriteConfigFile(); } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call WriteCategoryData() to persist /// their configuration settings. This overloading is used /// when there is more than one top-level XmlElement whose /// name is the name of the category. In that case, the /// one persisted is has a subelement whose name is /// subElementName and whose value is subElementValue. /// </summary> public void WriteCategoryData(ConfigCategory category, string subElementName, string subElementValue) { try { Monitor.Enter(this); XmlElement node = xmlDom.CreateElement("", category.GetName(), ""); category.WriteCategoryData(node); XmlElement oldNode = GetElementWithSubElementOfNameAndValue(category.GetName(), subElementName, subElementValue); if (oldNode != null) xmlRoot.ReplaceChild(node, oldNode); else xmlRoot.AppendChild(node); WriteConfigFile(); } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call WriteCategoryData() to persist /// their configuration settings. This overloading is used /// when there is only one top-level XmlElement whose name /// is the name of the category. /// </summary> public void WriteCategoryData(ConfigCategory category) { try { Monitor.Enter(this); XmlElement node = xmlDom.CreateElement("", category.GetName(), ""); category.WriteCategoryData(node); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); if (list.Count == 0) xmlRoot.AppendChild(node); else { if (list.Count > 1) { for (int i=1; i<list.Count; i++) xmlRoot.RemoveChild(list[i]); } xmlRoot.ReplaceChild(node, list[0]); } WriteConfigFile(); } finally { Monitor.Exit(this); } }