コード例 #1
0
        public void CreateOperationContains()
        {
            Operation operation = factory.CreateComparationContains(
                factory.CreateFieldNode("Field"),
                factory.CreateValueNode("Value", ValueNodeType.Text));

            Assert.IsNotNull(operation);
            Assert.AreEqual(typeof(OpContains), operation.GetType());
        }
コード例 #2
0
        /// <summary>
        /// COMPARATION Expression Rule
        ///  | FieldRule COMPARATOR ValueRule
        /// </summary>
        /// <returns>AST Operation Tree</returns>
        /// <exception cref="ParserException"><c>ParserException</c>.</exception>
        private Operation ComparationRule(FieldNode field)
        {
            _token = _scanner.GetToken();

            switch (_token.Ttype)
            {
            case TokenType.LESS:
                return(_astFactory.CreateComparationLess(field,
                                                         ValueRule()));

            case TokenType.GREATER:
                return(_astFactory.CreateComparationGreater(field,
                                                            ValueRule()));

            case TokenType.LESS_EQ:
                return(_astFactory.CreateComparationLessEqual(field,
                                                              ValueRule()));

            case TokenType.GREATER_EQ:
                return(_astFactory.CreateComparationGraterEqual(field,
                                                                ValueRule()));

            case TokenType.EQ:
                return(IsNullOrEqualRule(field));

            case TokenType.NOT_EQ:
                return(IsNotNullOrNotEqualRule(field));

            case TokenType.IS:
                return(IsNullOrNotIsNullRule(field));

            case TokenType.LIKE:
                return(_astFactory.CreateComparationContains(field, ValueRule()));

            default:
                throw new ParserException(
                          string.Format("Invalid Operation at {0}", _scanner.CurrentPosition));
            }
        }