/// <summary> /// Parses a <parameters> or <set> element in an XML parameter document /// </summary> /// <param name="parser">The XML parser</param> /// <param name="xmlNode">The XML node</param> /// <param name="parameters">The parameter set</param> /// <param name="modify">Do modify</param> private void ReadParamNode(XMLParser parser, XmlNode xmlNode, ref ParameterSet parameters, bool modify) { XmlNode childNode; ParameterSet newParams; string tag, values, childName, lang, dummy; try { parameters.Name = parser.GetAttrValue(xmlNode, "name"); // Name and version information. The version is passed to child sets during creation parameters.EnglishName = parameters.Name; if (parameters.NodeIsRoot()) { parameters.Version = parser.GetAttrValue(xmlNode, "version"); } childNode = parser.FirstElementChild(xmlNode, "translate"); // See if tbere's a translation of the name matching our current language setting while (childNode != null) { lang = parser.GetAttrValue(childNode, "lang"); dummy = parser.GetText(childNode); parameters.AddTranslation(lang, dummy); childNode = parser.NextElementSibling(childNode, "translate"); } if (!modify) { // If we are not modifying an existing parameter set, then clear any old child parameter sets while (parameters.ChildCount() > 0) { parameters.DeleteChild(parameters.ChildCount() - 1); } } values = parser.GetAttrValue(xmlNode, "locales").Trim(); // Populate the locale list parameters.SetLocaleText(values); childNode = parser.FirstElementChild(xmlNode, "par"); // Parse the <par> elements while (childNode != null) { tag = parser.GetAttrValue(childNode, "name"); values = parser.GetText(childNode); this.ReadParamValues(ref parameters, tag, values, modify); childNode = parser.NextElementSibling(childNode, "par"); } parameters.DeriveParams(); childNode = parser.FirstElementChild(xmlNode, "set"); // Create child parameter sets from the <set> elements while (childNode != null) { if (!modify) { newParams = parameters.AddChild(); } else { // If we are modifying an existing parameter set, then locate the child set that we are about to parse childName = parser.GetAttrValue(childNode, "name"); newParams = parameters.GetChild(childName); if (newParams == null) { newParams = parameters.AddChild(); } } this.ReadParamNode(parser, childNode, ref newParams, modify); childNode = parser.NextElementSibling(childNode, "set"); } } catch (Exception e) { throw new Exception(e.Message); } }