Esempio n. 1
0
        /// <summary>
        /// Sets the value of a parameter in a set, and optionally propagates the value
        /// to descendant parameter sets
        /// </summary>
        /// <param name="Params"></param>
        /// <param name="sTag"></param>
        /// <param name="sValue"></param>
        /// <param name="bPropagate"></param>
        private void assignParameter(ref TParameterSet Params, string sTag, string sValue, bool bPropagate)
        {
            int Idx;

            Params.setParam(sTag, sValue);
            if (bPropagate)
            {
                for (Idx = 0; Idx <= Params.iChildCount() - 1; Idx++)
                {
                    TParameterSet child = Params.getChild(Idx);
                    assignParameter(ref child, sTag, sValue, true);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a &lt;parameters&gt; or &lt;set&gt; 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);
            }
        }
Esempio n. 3
0
        /// <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);
        }