Beispiel #1
0
        internal static ExprItem ExprItem(string typeName)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName"));

            ExprItem exprItem = null;

            switch (typeName)
            {
            case "EXPR_LEAF":
                exprItem = new ExprLeaf();
                break;

            case "EXPR_UNARY_OPERATOR":
                exprItem = new ExprUnaryOperator();
                break;

            case "EXPR_BINARY_OPERATOR":
                exprItem = new ExprBinaryOperator();
                break;

            default:
                throw new NotSupportedException("type not supported: " + typeName);
            }

            DesignByContract.Check.Ensure(exprItem != null, "exprItem must not be null.");

            return(exprItem);
        }
Beispiel #2
0
        internal string GetPredicateFullPath(ExprItem exprItem)
        {
            ExprLeaf leaf = exprItem as ExprLeaf;

            if (leaf != null)
            {
                if (leaf.ReferenceType.IndexOf("path", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    return(leaf.Item.ToString());
                }
            }

            ExprUnaryOperator unarayOperand = exprItem as ExprUnaryOperator;

            if (unarayOperand != null)
            {
                ExprItem operand = unarayOperand.Operand;
                return(GetPredicateFullPath(operand));
            }

            PathExpr pathExpr = exprItem as PathExpr;

            if (pathExpr != null)
            {
                return(pathExpr.Path);
            }

            return(null);
        }
Beispiel #3
0
        protected void Validate(ExprUnaryOperator unaryOperator)
        {
            this.ValidateBase((ExprOperator)unaryOperator);

            Invariant(unaryOperator.Operand != null,
                      string.Format(CommonStrings.XMustNotBeNull, "unaryOperator.Operand"));
            this.Validate(unaryOperator.Operand);
        }
Beispiel #4
0
        private static ExprUnaryOperator Map(this EXPR_UNARY_OPERATOR model)
        {
            var unary = new ExprUnaryOperator
            {
                IsPrecedenceOverriden = model.precedence_overridden,
                Operand  = model.operand.Map(),
                Operator = (OperatorKind)((int)model.@operator)
            };

            return(unary);
        }