InvalidIsSyntax() публичный статический Метод

public static InvalidIsSyntax ( ) : Exception
Результат System.Exception
Пример #1
0
        internal override ExpressionNode Optimize()
        {
            left = left.Optimize();

            if (op == Operators.Is)
            {
                // only 'Is Null' or 'Is Not Null' are valid
                if (right is UnaryNode)
                {
                    UnaryNode un = (UnaryNode)right;
                    if (un.op != Operators.Not)
                    {
                        throw ExprException.InvalidIsSyntax();
                    }
                    op    = Operators.IsNot;
                    right = un.right;
                }
                if (right is ZeroOpNode)
                {
                    if (((ZeroOpNode)right).op != Operators.Null)
                    {
                        throw ExprException.InvalidIsSyntax();
                    }
                }
                else
                {
                    throw ExprException.InvalidIsSyntax();
                }
            }
            else
            {
                right = right.Optimize();
            }

#if DEBUG
            if (CompModSwitches.BinaryNode.TraceVerbose)
            {
                Debug.WriteLine("Optimizing " + this.ToString());
            }
#endif

            if (this.IsConstant())
            {
                object val = this.Eval();
#if DEBUG
                if (CompModSwitches.BinaryNode.TraceVerbose)
                {
                    Debug.WriteLine("the node value is " + val.ToString());
                }
#endif

                if (val == DBNull.Value)
                {
                    return(new ZeroOpNode(Operators.Null));
                }

                if (val is bool)
                {
                    if ((bool)val)
                    {
                        return(new ZeroOpNode(Operators.True));
                    }
                    else
                    {
                        return(new ZeroOpNode(Operators.False));
                    }
                }
#if DEBUG
                if (CompModSwitches.BinaryNode.TraceVerbose)
                {
                    Debug.WriteLine(val.GetType().ToString());
                }
#endif
                return(new ConstNode(ValueType.Object, val, false));
            }
            else
            {
                return(this);
            }
        }