コード例 #1
0
        /// <summary>
        /// Parses and returns a NOT expression.
        /// </summary>
        private static Expression ParseNot(IList <string> expressionTokens, ref int index)
        {
            string unaryOperator = string.Empty;

            if (Token(expressionTokens, index, true) == OperatorNot)
            {
                index++;
                unaryOperator = OperatorNot;
            }

            return(ExpressionUnary.Build(ParseRelational(expressionTokens, ref index), unaryOperator));
        }
コード例 #2
0
        /// <summary>
        /// Returns the recursive list of expressions (whether binary, unary, or relational)
        /// within the current XML element. Returns NULL if there is a failure.
        /// </summary>
        public static IList <Expression> AllExpressonsAsXml(XElement xExpression)
        {
            IList <Expression> expressions = new List <Expression>();

            foreach (XElement xExpressionRelation in XmlHelper.Children(xExpression, "ExpressionRelational"))
            {
                ExpressionRelational expressionRelational = new ExpressionRelational();
                if (!expressionRelational.ReadAsXml(xExpressionRelation))
                {
                    return(null);
                }

                expressions.Add(expressionRelational);
            }

            foreach (XElement xExpressionBinary in XmlHelper.Children(xExpression, "ExpressionBinary"))
            {
                ExpressionBinary expressionBinary = new ExpressionBinary();
                if (!expressionBinary.ReadAsXml(xExpressionBinary))
                {
                    return(null);
                }

                expressions.Add(expressionBinary);
            }

            foreach (XElement xExpressionUnary in XmlHelper.Children(xExpression, "ExpressionUnary"))
            {
                ExpressionUnary expressionUnary = new ExpressionUnary();
                if (!expressionUnary.ReadAsXml(xExpressionUnary))
                {
                    return(null);
                }

                expressions.Add(expressionUnary);
            }

            return(expressions);
        }