/// <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 GetCategoryData() to encache /// 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 /// right one to return is the one that has a subelement /// whose name is subElementName and whose value is /// subElementValue. /// </summary> public XmlElement GetCategoryData(ConfigCategory category, string subElementName, string subElementValue) { try { Monitor.Enter(this); return(GetElementWithSubElementOfNameAndValue(category.GetName(), subElementName, subElementValue)); } finally { Monitor.Exit(this); } }
/// <summary> /// Get rid of all elements whose name is the name of the category. /// </summary> public void RemoveChildrenOfCategory(ConfigCategory category) { try { Monitor.Enter(this); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); foreach (XmlNode node in list) { xmlRoot.RemoveChild(node); } } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call GetCategoryData() to encache /// 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 XmlElement GetCategoryData(ConfigCategory category) { try { Monitor.Enter(this); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); if (list.Count == 0) { return(null); } else if (list.Count > 1) { log.ErrorFormat("ConfigManager.Initialize: There are {0} nodes whose element name is '{0}'", category.GetName()); } XmlElement element = (XmlElement)list.Item(0); return(element); } 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); } }
/// <summary> /// Get rid of all elements whose name is the name of the category. /// </summary> public void RemoveChildrenOfCategory(ConfigCategory category) { try { Monitor.Enter(this); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); foreach (XmlNode node in list) xmlRoot.RemoveChild(node); } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call GetCategoryData() to encache /// 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 /// right one to return is the one that has a subelement /// whose name is subElementName and whose value is /// subElementValue. /// </summary> public XmlElement GetCategoryData(ConfigCategory category, string subElementName, string subElementValue) { try { Monitor.Enter(this); return GetElementWithSubElementOfNameAndValue(category.GetName(), subElementName, subElementValue); } finally { Monitor.Exit(this); } }
/// <summary> /// ConfigCategories call GetCategoryData() to encache /// 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 XmlElement GetCategoryData(ConfigCategory category) { try { Monitor.Enter(this); XmlNodeList list = xmlRoot.GetElementsByTagName(category.GetName()); if (list.Count == 0) return null; else if (list.Count > 1) log.ErrorFormat("ConfigManager.Initialize: There are {0} nodes whose element name is '{0}'", category.GetName()); XmlElement element = (XmlElement)list.Item(0); return element; } finally { Monitor.Exit(this); } }