示例#1
0
        private static string ConstantExpressionToTxt(XmlNode xml)
        {
            XmlNode valuexml = xml.SelectSingleNode("./*[@Key='Value']");

            string value = TextfieldToTxt.Parse(valuexml);
            string type  = xml.SelectSingleNode("./*[@Key='Value']").Name;

            if (type == "String")
            {
                value = "\"" + value + "\"";
            }

            return(value);
        }
示例#2
0
        public static void ParseCondition(XmlNode condition, out string conditionTxt, out string left, out string operatorType, out string right)
        {
            left         = "";
            right        = "";
            operatorType = "";
            conditionTxt = "";
            string xml = condition.OuterXml;

            if (xml.StartsWith("<BinaryExpression Key=\"Left\">") ||
                xml.StartsWith("<BinaryExpression Key=\"Right\">") ||
                xml.StartsWith("<BinaryExpression"))
            {
                XmlNodeList operators = condition.SelectNodes("BinaryOperator");
                operatorType = ConvertOperator(operators[operators.Count - 1].Attributes["Value"].Value);

                XmlNode Left = condition.SelectSingleNode("*[@Key='Left']");
                XmlNode Right = condition.SelectSingleNode("*[@Key='Right']");
                string  leftTxt, rightTxt, dummy;
                ParseCondition(Left, out leftTxt, out dummy, out dummy, out dummy);
                ParseCondition(Right, out rightTxt, out dummy, out dummy, out dummy);
                conditionTxt = "(" + leftTxt + " " + operatorType + " " + rightTxt + ")";
            }
            else if (xml.StartsWith("<CriteriaInputExpression"))
            {
                XmlNode child = condition.SelectSingleNode("*[@Key='InnerExpression']");
                string  dummy;
                ConditionXmlToTxt.ParseCondition(child, out conditionTxt, out dummy, out dummy, out dummy);
            }
            else if (xml.StartsWith("<GroupExpression") ||
                     xml.StartsWith("<BinaryExpression Key=\"Expression\">"))
            {
                XmlNode child = condition.ChildNodes[0];
                string  dummy;
                ConditionXmlToTxt.ParseCondition(child, out conditionTxt, out dummy, out dummy, out dummy);
            }
            else if (xml.StartsWith("<ConstantExpression"))
            {
                XmlNode DataType = condition.SelectSingleNode(".//DataType/@Value");
                string  value    = condition.SelectSingleNode(".//*[@Key='Value']/@Value").Value;
                if (DataType.Value == "String")
                {
                    conditionTxt = "\"" + value + "\"";
                }
                else
                {
                    conditionTxt = value;
                }
            }
            else if (xml.StartsWith("<StringConverterExpression"))
            {
                XmlNode child = condition.SelectSingleNode(".//*[@Key='Expression']");
                string  value, dummy;
                ConditionXmlToTxt.ParseCondition(child, out value, out dummy, out dummy, out dummy);
                conditionTxt = value;
            }
            else if (xml.StartsWith("<VariableExpression"))
            {
                XmlNode varxml = condition.SelectSingleNode(".//String[@Key='Name']/@Value");
                conditionTxt = "{" + varxml.Value + "}";
            }
            else if (xml.StartsWith("<ExpressionDecorator"))
            {
                XmlNode decorator = condition.SelectSingleNode("./*");
                string  dummy;
                ConditionXmlToTxt.ParseCondition(decorator, out conditionTxt, out dummy, out dummy, out dummy);
                if (conditionTxt.StartsWith("{") == false)
                {
                    conditionTxt = "{" + conditionTxt;
                }
                if (conditionTxt.EndsWith("}") == false)
                {
                    conditionTxt = conditionTxt + "}";
                }
            }
            else if (xml.StartsWith("<TrinaryExpression"))
            {
            }
            else if (xml.StartsWith("<StepResultExpression"))
            {
                XmlNode varxml = condition.SelectSingleNode(".//*[@Key='Result']/@Value");
                conditionTxt = "{" + varxml.Value + "}";
            }
            else if (xml.StartsWith("<FunctionCall"))
            {
                XmlNode function   = condition.SelectSingleNode(".//*[@Key='FunctionName']");
                string  funcname   = function.Attributes["Value"].Value;
                XmlNode parameters = condition.SelectSingleNode(".//*[@Key='Parameters']/*");

                if (parameters != null)
                {
                    string paramsTxt, dummy;
                    ConditionXmlToTxt.ParseCondition(parameters, out paramsTxt, out dummy, out dummy, out dummy);

                    conditionTxt = funcname + "(" + paramsTxt + ")";
                }
                else
                {
                    conditionTxt = funcname;
                }
            }
            else if (xml.StartsWith("<IndexedVariableExpression") ||
                     xml.StartsWith("<IndexedMatrixVariableExpression") ||
                     xml.StartsWith("<MatrixSubColVariableExpression") ||
                     xml.StartsWith("<MatrixSubRowVariableExpression") ||
                     xml.StartsWith("<RangeIndexedMatrixVariableExpression") ||
                     xml.StartsWith("<RangeIndexedVariableExpression") ||
                     xml.StartsWith("<RowRangeIndexedMatrixVariableExpression") ||
                     xml.StartsWith("<MatrixRowVariableExpressionLogicalTreeProvider") ||
                     xml.StartsWith("<UnaryExpression") ||
                     xml.StartsWith("<ConcatenationExpression") ||
                     xml.StartsWith("<VectorBuilder") ||
                     xml.StartsWith("<Null"))
            {
                conditionTxt = TextfieldToTxt.Parse(condition);
                return;
            }
            else if (xml.StartsWith("<ParameterExpressionBinder"))
            {
            }
            else if (xml.StartsWith("<CriteriaInputExpression"))
            {
            }
            else if (xml.StartsWith("<MatrixColVariableExpressionLogicalTreeProvider"))
            {
                conditionTxt = TextfieldToTxt.Parse(condition);
            }
            else if (xml.StartsWith("<MemberExpression"))
            {
                if (condition.FirstChild.Name == "MemberExpression")
                {
                    XmlNode     Left  = condition.SelectSingleNode(".//String[@Key='Name' or @Key='FunctionName']");
                    XmlNodeList Right = condition.SelectNodes(".//*[@Key='Right']");
                    conditionTxt = "{" + Left.Attributes["Value"].Value + "."; // +Right.Attributes["Value"].Value + "}";
                    int rc = 0;
                    foreach (XmlNode r in Right)
                    {
                        conditionTxt += r.Attributes["Value"].Value;
                        if (rc < Right.Count - 1)
                        {
                            conditionTxt += ".";
                        }

                        rc++;
                    }
                    conditionTxt += "}";
                }
                else
                {
                    XmlNode Left  = condition.SelectSingleNode(".//String[@Key='Name' or @Key='FunctionName']");
                    XmlNode Right = condition.SelectSingleNode("*[@Key='Right']");
                    conditionTxt = "{" + Left.Attributes["Value"].Value + "." + Right.Attributes["Value"].Value + "}";
                }
            }
            else
            {
                conditionTxt = "ConditionXmlToTxt.ParseCondition - unidentified condition: " + condition.Name;
            }

            if (conditionTxt.Length == 0)
            {
                conditionTxt = "ConditionXmlToTxt.ParseCondition - unhandled condition: " + condition.Name;
            }
        }
        private static string ParseAction(XmlNode action, int indentLevel)
        {
            string output       = "";
            string indentString = new string(' ', indentLevel * 4);

            string name           = action.SelectSingleNode(".//*[@Key=\"Name\"]/@Value").Value;
            string scope          = action.SelectSingleNode(".//*[@Key=\"Scope\"]/@Value").Value;
            string retryCount     = TextfieldToTxt.Parse(action.SelectSingleNode(".//*[@Key=\"RetryCount\"]"));
            string retryInterval  = TextfieldToTxt.Parse(action.SelectSingleNode(".//*[@Key=\"RetryInterval\"]"));
            string isRetryEnabled = action.SelectSingleNode(".//*[@Key=\"IsRetryEnabled\"]/@Value").Value;

            output = indentString + "/* Action Type: " + action.Name + " */" + "\r\n";
            switch (action.Name)
            {
            case "RetryAction":
                output += indentString + name + "(Retry " + scope + " in " + retryInterval + " seconds, a maximum of " + retryCount + " times)";
                break;

            case "RestartSessionAction":
                string session            = TextfieldToTxt.Parse(action.SelectSingleNode(".//*[@Key=\"Session\"]"));
                string delayBeforeRestart = TextfieldToTxt.Parse(action.SelectSingleNode(".//*[@Key=\"DelayBeforeRestart\"]"));
                output += indentString + name + "(Wait " + delayBeforeRestart + " seconds and restart " + session + ".";
                if (isRetryEnabled == "True")
                {
                    output += " If action succeeds, retry " + scope + " in " + retryInterval + " seconds, a maximum of " + retryCount + " times)";
                }
                else
                {
                    output += ")";
                }
                break;

            case "RunCodeAction":
                string code = action.SelectSingleNode(".//*[@Key=\"Code\"]/@Value").Value;
                output += indentString + name + "(Execute the code below.";
                if (isRetryEnabled == "True")
                {
                    output += " If action succeeds, retry " + scope + " in " + retryInterval + " seconds, a maximum of " + retryCount + " times)";
                }
                else
                {
                    output += ")";
                }
                output += "\r\n" + indentString + "/***** Matshell code *****/" + "\r\n";
                output += indentString + code.Replace("_x000D__x000A_", "\r\n" + indentString);
                output += "\r\n" + indentString + "/*** Matshell code end ***/" + "\r\n";

                break;

            case "PaWRunFunction":
            case "RunFunction":
                XmlNode testTool = action.SelectSingleNode(".//PaWTestTool");
                string  testlog, dummy;
                string  testname = testTool.SelectSingleNode(".//*[@Key=\"Name\"]/@Value").Value.Replace(".tsdrv", "").Replace(".tstest", "");
                TestTool.TestToTxt(testTool, indentLevel, out testlog, out dummy);
                output += indentString + testname.Replace("_x0020_", "_") + testlog;
                if (isRetryEnabled == "True")
                {
                    output += "\r\n" + indentString + "If action succeeds, retry " + scope + " in " + retryInterval + " seconds, a maximum of " + retryCount + " times";
                }

                break;

            default:
                break;
            }

            return(output);
        }
示例#4
0
        public static string Parse(XmlNode node)
        {
            string output = null;
            string xml    = node.OuterXml;


            if (xml.StartsWith("<ConstantExpression"))
            {
                output = ConstantExpressionToTxt(node);
            }
            else if (xml.StartsWith("<ConcatenationExpression"))
            {
                XmlNode concatType = node.SelectSingleNode(".//StringExpressionsConcator/@Key");
                if (concatType == null)
                {
                    concatType = node.SelectSingleNode(".//PasswordExpressionsConcator/@Key");
                }
                if (concatType == null)
                {
                    concatType = node.SelectSingleNode(".//Null/@Key");
                }

                if (concatType.Value == "Concator")
                {
                    XmlNodeList parts = node.SelectNodes(".//List/*");
                    string      dummy;
                    string      curpart;
                    output = "";
                    foreach (XmlNode part in parts)
                    {
                        ConditionXmlToTxt.ParseCondition(part, out curpart, out dummy, out dummy, out dummy);
                        output += curpart;
                    }
                }
                else
                {
                    output = "TextfieldToTxt - ConcatenationExpression - unknown concatenation type: " + concatType.Value;
                }
            }
            else if (xml.StartsWith("<StringConcatenationExpression"))
            {
                XmlNodeList parts = node.SelectNodes(".//List/*");
                string      dummy;
                string      curpart;
                output = "";
                foreach (XmlNode part in parts)
                {
                    ConditionXmlToTxt.ParseCondition(part, out curpart, out dummy, out dummy, out dummy);
                    output += curpart;
                }
            }
            else if (xml.StartsWith("<BinaryExpression") ||
                     xml.StartsWith("<GroupExpression") ||
                     xml.StartsWith("<MemberExpression") ||
                     xml.StartsWith("<ExpressionDecorator"))
            {
                string dummy;
                ConditionXmlToTxt.ParseCondition(node, out output, out dummy, out dummy, out dummy);
            }
            else if (xml.StartsWith("<VariableExpression"))
            {
                output = VariableExpressionToTxt(node);
            }
            else if (xml.StartsWith("<Null"))
            {
                output = "";
            }
            else if (xml.StartsWith("<RangeIndexedVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Vector")
                {
                    string  variable = TextfieldToTxt.Parse(node.SelectSingleNode("*"));
                    XmlNode rowstart = node.SelectSingleNode(".//Range/*[@Key='Start']");
                    XmlNode rowend   = node.SelectSingleNode(".//Range/*[@Key='End']");

                    output = variable.Replace("}", "(" + TextfieldToTxt.Parse(rowstart) + ":" + TextfieldToTxt.Parse(rowend) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - RangeIndexedVariableExpression - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<AssignmentStatement"))
            {
                string source       = TextfieldToTxt.Parse(node.SelectSingleNode(".//*[@Key='Source']"));
                string target       = TextfieldToTxt.Parse(node.SelectSingleNode(".//*[@Key='Target']"));
                string operatorType = node.SelectSingleNode(".//AssignmentOperator/@Value").Value;

                output = target;
                switch (operatorType)
                {
                case "Assignment":
                    output += " = " + source;
                    break;

                case "PlusAssignment":
                    output += " += " + source;
                    break;

                case "MinusAssignment":
                    output += " -= " + source;
                    break;

                case "MultiplyAssignment":
                    output += " *= " + source;
                    break;

                case "DivideAssignment":
                    output += " /= " + source;
                    break;

                default:
                    output += " TextfieldToTxt - AssignmentStatement - unknown operator: " + operatorType + " " + source;
                    break;
                }
            }
            else if (xml.StartsWith("<IndexedVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Vector")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode col      = node.SelectSingleNode("*[@Key='Index']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(col) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - IndexedVariableExpression - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<FunctionCall"))
            {
                string dummy;
                ConditionXmlToTxt.ParseCondition(node, out output, out dummy, out dummy, out dummy);
            }
            else if (xml.StartsWith("<CodeBlock"))
            {
                output = "";
                XmlNodeList innerList = node.SelectSingleNode(".//List[@Key='Statements']").ChildNodes;

                foreach (XmlNode statement in innerList)
                {
                    output += TextfieldToTxt.Parse(statement) + "\r\n";
                }
            }
            else if (xml.StartsWith("<IndexedMatrixVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode row      = node.SelectSingleNode("*[@Key='IndexRow']");
                    XmlNode col      = node.SelectSingleNode("*[@Key='IndexCol']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(row) + "," + TextfieldToTxt.Parse(col) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - IndexedMatrixVariableExpression - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<MatrixSubColVariableExpressionLogicalTreeProvider"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode rowstart = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='Start']");
                    XmlNode rowend   = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='End']");
                    XmlNode col      = node.SelectSingleNode("*[@Key='ColIndex']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(rowstart) + ":" + TextfieldToTxt.Parse(rowend) + "," + TextfieldToTxt.Parse(col) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - MatrixSubColVariableExpressionLogicalTreeProvider - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<MatrixSubRowVariableExpressionLogicalTreeProvider"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode colstart = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='Start']");
                    XmlNode colend   = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='End']");
                    XmlNode row      = node.SelectSingleNode("*[@Key='RowIndex']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(row) + "," + TextfieldToTxt.Parse(colstart) + ":" + TextfieldToTxt.Parse(colend) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - MatrixSubRowVariableExpressionLogicalTreeProvider - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<RangeIndexedMatrixVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode rowstart = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='Start']");
                    XmlNode rowend   = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='End']");
                    XmlNode colstart = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='Start']");
                    XmlNode colend   = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='End']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(rowstart) + ":" + TextfieldToTxt.Parse(rowend) + "," + TextfieldToTxt.Parse(colstart) + ":" + TextfieldToTxt.Parse(colend) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - MatrixSubColVariableExpressionLogicalTreeProvider - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<MatrixColVariableExpressionLogicalTreeProvider"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode col      = node.SelectSingleNode("*[@Key='ColIndex']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(:," + TextfieldToTxt.Parse(col) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - MatrixColVariableExpressionLogicalTreeProvider - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<MatrixRowVariableExpressionLogicalTreeProvider"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode row      = node.SelectSingleNode("*[@Key='RowIndex']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(row) + ",:)}");
                }
                else
                {
                    output = "TextfieldToTxt - MatrixRowVariableExpressionLogicalTreeProvider - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<RowRangeIndexedMatrixVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode rowstart = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='Start']");
                    XmlNode rowend   = node.SelectSingleNode(".//Range[@Key='RowRange']/*[@Key='End']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(" + TextfieldToTxt.Parse(rowstart) + ":" + TextfieldToTxt.Parse(rowend) + ",:)}");
                }
                else
                {
                    output = "TextfieldToTxt - RowRangeIndexedMatrixVariableExpression - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<ColRangeIndexedMatrixVariableExpression"))
            {
                XmlNode dimension = node.SelectSingleNode("*/@Key");

                if (dimension.Value == "Matrix")
                {
                    XmlNode variable = node.SelectSingleNode("*");
                    XmlNode colstart = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='Start']");
                    XmlNode colend   = node.SelectSingleNode(".//Range[@Key='ColRange']/*[@Key='End']");

                    output = TextfieldToTxt.Parse(variable).Replace("}", "(:," + TextfieldToTxt.Parse(colstart) + ":" + TextfieldToTxt.Parse(colend) + ")}");
                }
                else
                {
                    output = "TextfieldToTxt - ColRangeIndexedMatrixVariableExpression - unknown dimension: " + dimension.Value;
                }
            }
            else if (xml.StartsWith("<Boolean ") ||
                     xml.StartsWith("<Double ") ||
                     xml.StartsWith("<DataDimension ") ||
                     xml.StartsWith("<String ") ||
                     xml.StartsWith("<ReadBufferType ") ||
                     xml.StartsWith("<DllHostType ") ||
                     xml.StartsWith("<PaddingOptions ") ||
                     xml.StartsWith("<LaunchMode ") ||
                     xml.StartsWith("<Int32 "))
            {
                output = node.Attributes["Value"].Value;
            }
            else if (xml.StartsWith("<TrimWhitespaceOptions"))
            {
                output = node.Attributes["Value"].Value;
            }
            else if (xml.StartsWith("<Password "))
            {
                output = "\"" + node.SelectSingleNode(".//*[@Key='Password']/@Value").Value + "\"" + " // (encrypted value)";
            }
            else if (xml.StartsWith("<VectorString"))
            {
                XmlNodeList elements = node.SelectNodes(".//*[@Key='Elements']/KeyValuePair");
                int         count    = int.Parse(node.SelectSingleNode(".//*[@Key='Size']/@Value").Value);
                output = "";
                string[] values = new string[count];
                for (int i = 0; i < count; i++)
                {
                    values[i] = "\"\"";
                }

                foreach (XmlNode element in elements)
                {
                    int    index = int.Parse(element.SelectSingleNode(".//*[@Key='HashKey']/@Value").Value);
                    string value = element.SelectSingleNode(".//*[@Key='HashValue']/@Value").Value;
                    values[index] = "\"" + value + "\"";
                }
                output = "[" + String.Join(", ", values) + "]";
            }
            else if (xml.StartsWith("<VectorNumeric"))
            {
                XmlNodeList elements = node.SelectNodes(".//*[@Key='Elements']/KeyValuePair");
                int         count    = int.Parse(node.SelectSingleNode(".//*[@Key='ElementCount']/@Value").Value);
                output = "";
                int[] numbers = new int[count];
                Array.Clear(numbers, 0, numbers.Length);
                foreach (XmlNode element in elements)
                {
                    int index = int.Parse(element.SelectSingleNode(".//*[@Key='HashKey']/@Value").Value);
                    int value = int.Parse(element.SelectSingleNode(".//*[@Key='HashValue']/@Value").Value);
                    numbers[index] = value;
                }
                output = "[" + String.Join(", ", numbers) + "]";
            }
            else if (xml.StartsWith("<MatrixString") ||
                     xml.StartsWith("<MatrixNumeric"))
            {
                XmlNodeList vectors = node.SelectNodes(".//List[@Key='Vectors']/*");
                string      curpart;
                output = "";
                int c = 0;
                foreach (XmlNode vect in vectors)
                {
                    curpart = TextfieldToTxt.Parse(vect);
                    curpart = curpart.Substring(1, curpart.Length - 2);
                    output += curpart + "; ";
                    c++;
                }
                if (output.Length == 0)
                {
                    output = "[;]";
                }
                else
                {
                    output = "[" + output + "]";
                }
            }
            else if (xml.StartsWith("<RangeEndExpression"))
            {
                output = "end";
            }
            else if (xml.StartsWith("<SessionInfo"))
            {
                if (node.SelectSingleNode(".//Guid/@Value").Value == "00000000-0000-0000-0000-000000000000")
                {
                    output = "null";
                }
                else
                {
                    output = "TextfieldToTxt - SessionInfo - unhandled session with id";
                }
            }
            else if (xml.StartsWith("<NamedParameterInfo"))
            {
                string name  = node.SelectSingleNode(".//*[@Key='Name']/@Value").Value;
                string value = TextfieldToTxt.Parse(node.SelectSingleNode(".//*[@Key='Value']"));
                output = name + " = " + value;
            }
            else if (xml.StartsWith("<VectorBuilder"))
            {
                XmlNodeList cells = node.SelectNodes(".//*[@Key='Cells']/*");
                string      dummy;
                string      curpart;
                output = "";
                int c = 0;
                foreach (XmlNode cell in cells)
                {
                    ConditionXmlToTxt.ParseCondition(cell, out curpart, out dummy, out dummy, out dummy);
                    output += curpart + (c < cells.Count - 1 ? ", ":"");
                    c++;
                }
                output = "[" + output + "]";
            }
            else if (xml.StartsWith("<WhileStatement"))
            {
                XmlNode codeblock = node.SelectSingleNode(".//*[@Key='CodeBlock']");
                XmlNode condition = node.SelectSingleNode(".//*[@Key='Condition']");
                bool    isDoWhile = bool.Parse(node.SelectSingleNode(".//*[@Key='IsVerifyAfter']/@Value").Value);

                if (isDoWhile)
                {
                    output  = "do" + "\r\n";
                    output += TextfieldToTxt.Parse(codeblock);
                    output += "while" + TextfieldToTxt.Parse(condition) + "\r\n";
                }
                else
                {
                    output  = "while " + TextfieldToTxt.Parse(condition) + "\r\n";
                    output += TextfieldToTxt.Parse(codeblock) + "end" + "\r\n";
                }
            }
            else if (xml.StartsWith("<ForStatement"))
            {
                XmlNode codeblock = node.SelectSingleNode(".//*[@Key='CodeBlock']");
                XmlNode index     = node.SelectSingleNode(".//*[@Key='Index']");
                XmlNode binary    = node.SelectSingleNode(".//BinaryExpression");

                output  = "for (" + TextfieldToTxt.Parse(index) + " = " + TextfieldToTxt.Parse(binary) + ")" + "\r\n";
                output += TextfieldToTxt.Parse(codeblock) + "end" + "\r\n";
            }
            else if (xml.StartsWith("<IfStatement") || xml.StartsWith("<ConditionedCodeBlock"))
            {
                XmlNode codeblock = node.SelectSingleNode(".//*[@Key='CodeBlock']");
                XmlNode condition = node.SelectSingleNode(".//*[@Key='Condition']");
                XmlNode elseblock = node.SelectSingleNode(".//*[@Key='Else']");
                XmlNode elseifs   = node.SelectSingleNode(".//*[@Key='ElseIfs']");

                output  = "if " + TextfieldToTxt.Parse(condition) + "\r\n";
                output += TextfieldToTxt.Parse(codeblock);

                if (elseifs != null && elseifs.ChildNodes.Count > 0)
                {
                    foreach (XmlNode item in elseifs.ChildNodes)
                    {
                        output += "else" + TextfieldToTxt.Parse(item);
                    }
                }

                if (elseblock != null && elseblock.Name != "Null")
                {
                    output += "else" + "\r\n";
                    output += TextfieldToTxt.Parse(elseblock);
                }

                if (xml.StartsWith("<IfStatement"))
                {
                    output += "end";
                }
            }
            else if (xml.StartsWith("<UnaryExpression"))
            {
                string target       = TextfieldToTxt.Parse(node.SelectSingleNode(".//*[@Key='Expression']"));
                string operatorType = node.SelectSingleNode(".//UnaryOperator/@Value").Value;
                if (operatorType == "AutoIncrement")
                {
                    output = target + "++";
                }
                else if (operatorType == "AutoDecrement")
                {
                    output = target + "--";
                }
                else if (operatorType == "Negate")
                {
                    output = "-" + target;
                }
                else
                {
                    output = "TextfieldToTxt - UnaryExpression - unknown operator: " + operatorType;
                }
            }
            else if (xml.StartsWith("<MatrixBuilder"))
            {
                XmlNodeList lists = node.SelectNodes(".//*[@Key='Cells']/*");
                string      dummy;
                string      curpart;
                output = "";
                int c = 0;
                foreach (XmlNode list in lists)
                {
                    XmlNodeList cells = list.SelectNodes("./*");
                    foreach (XmlNode cell in cells)
                    {
                        ConditionXmlToTxt.ParseCondition(cell, out curpart, out dummy, out dummy, out dummy);
                        output += curpart + (c < cells.Count - 1 ? ", " : "");
                        c++;
                    }
                    output += ";";
                }
                output = "[" + output + "]";
            }
            else
            {
                return("TextfieldToTxt - unidentified xml: " + xml);
            }

            if (output == null)
            {
                return("TextfieldToTxt - not implemented xml: " + node.Name);
            }

            return(output);
        }