Exemple #1
0
        /// <summary>
        /// Parses the contents of a &lt;par&gt; element in an XML parameter document.
        /// </summary>
        /// <param name="Params"></param>
        /// <param name="sTag"></param>
        /// <param name="sValues"></param>
        /// <param name="bPropagate"></param>
        private void readParamValues(ref ParameterSet Params, string sTag, string sValues, bool bPropagate)
        {
            ParameterDefinition Definition;
            string sValue;
            int    Idx;

            sValues = sValues.Trim();

            if ((sTag != "") && (sValues != ""))
            {
                Definition = Params.GetDefinition(sTag);
                if ((Definition == null) || (Definition.iDimension() > 1))
                {
                    throw new Exception("Invalid tag when reading parameters: " + sTag);
                }

                if (Definition.bIsScalar())                                                // Reference to a single value
                {
                    assignParameter(ref Params, sTag, sValues, bPropagate);
                }
                else
                {                                                                      // Reference to a list of values
                    for (Idx = 0; Idx <= Definition.iCount - 1; Idx++)
                    {
                        sValue = stripValue(ref sValues);
                        if (sValue != "")                                                      // Null string denotes "leave value at
                        {
                            assignParameter(ref Params, sTag + Definition.item(Idx).sPartName, //   default"
                                            sValue, bPropagate);
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Parses the contents of a &lt;par&gt; element in an XML parameter document.
        /// </summary>
        /// <param name="parameters">The parameter set</param>
        /// <param name="tagName">The tag name</param>
        /// <param name="values">The value string</param>
        /// <param name="propagate">Do propagate</param>
        private void ReadParamValues(ref ParameterSet parameters, string tagName, string values, bool propagate)
        {
            ParameterDefinition paramDefinition;
            string value;

            values = values.Trim();

            if ((tagName != string.Empty) && (values != string.Empty))
            {
                paramDefinition = parameters.GetDefinition(tagName);
                if ((paramDefinition == null) || (paramDefinition.Dimension() > 1))
                {
                    throw new Exception("Invalid tag when reading parameters: " + tagName);
                }

                if (paramDefinition.IsScalar())
                {
                    // Reference to a single value
                    this.AssignParameter(ref parameters, tagName, values, propagate);
                }
                else
                {
                    // Reference to a list of values
                    for (int idx = 0; idx <= paramDefinition.Count - 1; idx++)
                    {
                        value = this.StripValue(ref values);
                        if (value != string.Empty)
                        {
                            // Null string denotes "leave value at default"
                            this.AssignParameter(ref parameters, tagName + paramDefinition.Item(idx).PartName, value, propagate);
                        }
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Write the parameter set
        /// </summary>
        /// <param name="subSet">The parameter subset</param>
        /// <param name="strings">List of strings</param>
        /// <param name="elem">XML element name</param>
        /// <param name="indent">The XML indentation</param>
        private void WriteParamSet(ParameterSet subSet, List <string> strings, string elem, int indent)
        {
            string lineStr;
            int    idx;

            if (!subSet.NodeIsRoot())
            {
                strings.Add(string.Empty);
            }

            lineStr = new string(' ', indent) + "<" + elem + " name=\"" + subSet.EnglishName + "\"";
            if (subSet.NodeIsRoot())
            {
                lineStr += " version=\"" + subSet.Version + "\">";
            }
            else
            {
                if (subSet.LocaleCount() > 0)
                {
                    lineStr += " locales=\"" + subSet.GetLocale(0);
                    for (idx = 1; idx <= subSet.LocaleCount() - 1; idx++)
                    {
                        lineStr += ";" + subSet.GetLocale(idx);
                    }
                    lineStr += "\"";
                }
                lineStr += ">";
            }
            strings.Add(lineStr);

            if (subSet.TranslationCount() > 0)
            {
                for (idx = 0; idx <= subSet.TranslationCount() - 1; idx++)
                {
                    lineStr = new string(' ', indent + 2) + "<translate lang=\"" +
                              subSet.GetTranslation(idx).Lang + "\">" +
                              EscapeText(subSet.GetTranslation(idx).Text) + "</translate>";
                    strings.Add(lineStr);
                }
            }

            for (idx = 0; idx <= subSet.DefinitionCount() - 1; idx++)
            {
                this.WriteParameters(subSet, subSet.GetDefinition(idx), strings, indent + 2);
            }
            for (idx = 0; idx <= subSet.ChildCount() - 1; idx++)
            {
                this.WriteParamSet(subSet.GetChild(idx), strings, "set", indent + 2);
            }

            lineStr = new string(' ', indent) + "</" + elem + ">";
            if (!subSet.NodeIsRoot() && (subSet.ChildCount() > 0))
            {
                lineStr += "<!-- " + subSet.EnglishName + " -->";
            }

            strings.Add(lineStr);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subSet"></param>
        /// <param name="Strings"></param>
        /// <param name="sElem"></param>
        /// <param name="iIndent"></param>
        private void writeParamSet(ParameterSet subSet,
                                   List <string> Strings,
                                   string sElem,
                                   int iIndent)
        {
            string sLine;
            int    Idx;

            if (!subSet.NodeIsRoot())
            {
                Strings.Add("");
            }

            sLine = new string(' ', iIndent) + "<" + sElem + " name=\"" + subSet.sEnglishName + "\"";
            if (subSet.NodeIsRoot())
            {
                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.DefinitionCount() - 1; Idx++)
            {
                writeParameters(subSet, subSet.GetDefinition(Idx), Strings, iIndent + 2);
            }
            for (Idx = 0; Idx <= subSet.ChildCount() - 1; Idx++)
            {
                writeParamSet(subSet.GetChild(Idx), Strings, "set", iIndent + 2);
            }

            sLine = new string(' ', iIndent) + "</" + sElem + ">";
            if (!subSet.NodeIsRoot() && (subSet.ChildCount() > 0))
            {
                sLine += "<!-- " + subSet.sEnglishName + " -->";
            }

            Strings.Add(sLine);
        }