/// <summary> /// /// </summary> /// <param name="subSet"></param> /// <param name="Strings"></param> /// <param name="sElem"></param> /// <param name="iIndent"></param> private void writeParamSet(TParameterSet subSet, List<string> Strings, string sElem, int iIndent) { string sLine; int Idx; if (!subSet.bRootNode()) Strings.Add(""); sLine = new string(' ', iIndent) + "<" + sElem + " name=\"" + subSet.sEnglishName + "\""; if (subSet.bRootNode()) sLine += " version=\"" + subSet.sVersion + "\">"; else { if (subSet.iLocaleCount() > 0) { sLine += " locales=\"" + subSet.getLocale(0); for (Idx = 1; Idx <= subSet.iLocaleCount() - 1; Idx++) sLine += ";" + subSet.getLocale(Idx); sLine += "\""; } sLine += ">"; } Strings.Add(sLine); if (subSet.iTranslationCount() > 0) for (Idx = 0; Idx <= subSet.iTranslationCount() - 1; Idx++) { sLine = new string(' ', iIndent + 2) + "<translate lang=\"" + subSet.getTranslation(Idx).sLang + "\">" + TTypedValue.escapeText(subSet.getTranslation(Idx).sText) + "</translate>"; Strings.Add(sLine); } for (Idx = 0; Idx <= subSet.iDefinitionCount() - 1; Idx++) writeParameters(subSet, subSet.getDefinition(Idx), Strings, iIndent + 2); for (Idx = 0; Idx <= subSet.iChildCount() - 1; Idx++) writeParamSet(subSet.getChild(Idx), Strings, "set", iIndent + 2); sLine = new string(' ', iIndent) + "</" + sElem + ">"; if (!subSet.bRootNode() && (subSet.iChildCount() > 0)) sLine += "<!-- " + subSet.sEnglishName + " -->"; Strings.Add(sLine); }
/// <summary> /// Parses a <parameters> or <set> element in an XML parameter document /// </summary> /// <param name="Parser"></param> /// <param name="aNode"></param> /// <param name="Params"></param> /// <param name="bModify"></param> private void readParamNode(TXMLParser Parser, XmlNode aNode, ref TParameterSet Params, bool bModify) { XmlNode childNode; TParameterSet newParams; string sTag, sValues, sChildName, sLang, sDummy; try { Params.sName = Parser.getAttrValue(aNode, "name"); // Name and version information. The Params.sEnglishName = Params.sName; if (Params.bRootNode()) // version is passed to child sets Params.sVersion = Parser.getAttrValue(aNode, "version"); // during creation childNode = Parser.firstElementChild(aNode, "translate"); // See if tbere's a translation of the name matching our current language setting while (childNode != null) { sLang = Parser.getAttrValue(childNode, "lang"); sDummy = Parser.getText(childNode); Params.addTranslation(sLang, sDummy); childNode = Parser.nextElementSibling(childNode, "translate"); } if (!bModify) // If we are not modifying an existing while (Params.iChildCount() > 0) // parameter set, then clear any old Params.deleteChild(Params.iChildCount() - 1); // child parameter sets sValues = Parser.getAttrValue(aNode, "locales").Trim(); // Populate the locale list Params.setLocaleText(sValues); childNode = Parser.firstElementChild(aNode, "par"); // Parse the <par> elements while (childNode != null) { sTag = Parser.getAttrValue(childNode, "name"); sValues = Parser.getText(childNode); readParamValues(ref Params, sTag, sValues, bModify); childNode = Parser.nextElementSibling(childNode, "par"); } Params.deriveParams(); childNode = Parser.firstElementChild(aNode, "set"); // Create child parameter sets from the while (childNode != null) // <set> elements { if (!bModify) newParams = Params.addChild(); else { // If we are modifying an existing sChildName = Parser.getAttrValue(childNode, "name"); // parameter set, then locate the child newParams = Params.getChild(sChildName); // set that we are about to parse if (newParams == null) newParams = Params.addChild(); } readParamNode(Parser, childNode, ref newParams, bModify); childNode = Parser.nextElementSibling(childNode, "set"); } } catch (Exception e) { throw new Exception(e.Message); } }