Beispiel #1
0
        /// <summary>
        /// Write parameters out
        /// </summary>
        /// <param name="subSet">Parameter subset</param>
        /// <param name="paramDefinition">The parameter definition</param>
        /// <param name="strings">List of string values</param>
        /// <param name="indent">The indent to use</param>
        private void WriteParameters(ParameterSet subSet, ParameterDefinition paramDefinition, List <string> strings, int indent)
        {
            int    diffCount;
            string lineStr;
            int    idx;

            if (paramDefinition.Dimension() > 1)
            {
                // Multi-dimensional array of parameters - recurse
                for (idx = 0; idx <= paramDefinition.Count - 1; idx++)
                {
                    this.WriteParameters(subSet, paramDefinition.Item(idx), strings, indent);
                }
            }
            else if (paramDefinition.IsScalar() && this.Differs(subSet, paramDefinition))
            {
                // Single parameter value
                lineStr = new string(' ', indent)
                          + "<par name=\"" + paramDefinition.FullName + "\">"
                          + subSet.ParamStr(paramDefinition.FullName)
                          + "</par>";
                strings.Add(lineStr);
            }
            else
            {
                // List of parameter values (one-dimensional)
                diffCount = 0;
                for (idx = 0; idx <= paramDefinition.Count - 1; idx++)
                {
                    if (this.Differs(subSet, paramDefinition.Item(idx)))
                    {
                        diffCount++;
                    }
                }

                if (diffCount > 1)
                {
                    // More than one difference - write the differing values in a list
                    lineStr = new string(' ', indent)
                              + "<par name=\"" + paramDefinition.FullName + "\">";
                    for (idx = 0; idx <= paramDefinition.Count - 1; idx++)
                    {
                        if (idx > 0)
                        {
                            lineStr += ',';
                        }
                        if (this.Differs(subSet, paramDefinition.Item(idx)))
                        {
                            lineStr += subSet.ParamStr(paramDefinition.Item(idx).FullName);
                        }
                    }
                    lineStr += "</par>";
                    strings.Add(lineStr);
                }
                else if (diffCount == 1)
                {
                    // Only one parameter is different - write it as a scalar
                    for (idx = 0; idx <= paramDefinition.Count - 1; idx++)
                    {
                        if (this.Differs(subSet, paramDefinition.Item(idx)))
                        {
                            this.WriteParameters(subSet, paramDefinition.Item(idx), strings, indent);
                        }
                    }
                }
            }
        }