private QueryExpression ParseExpression()
        {
            QueryExpression     rootExpression   = null;
            CompositeExpression parentExpression = null;

            while (_currentIndex < _expression.Length)
            {
                EatWhitespace();

                if (_expression[_currentIndex] != '@')
                {
                    throw new JsonException("Unexpected character while parsing path query: " + _expression[_currentIndex]);
                }

                _currentIndex++;

                List <PathFilter> expressionPath = new List <PathFilter>();

                if (ParsePath(expressionPath, _currentIndex, true))
                {
                    throw new JsonException("Path ended with open query.");
                }

                EatWhitespace();
                EnsureLength("Path ended with open query.");

                QueryOperator op;
                object        value = null;
                if (_expression[_currentIndex] == ')' ||
                    _expression[_currentIndex] == '|' ||
                    _expression[_currentIndex] == '&')
                {
                    op = QueryOperator.Exists;
                }
                else
                {
                    op = ParseOperator();

                    EatWhitespace();
                    EnsureLength("Path ended with open query.");

                    value = ParseValue();

                    EatWhitespace();
                    EnsureLength("Path ended with open query.");
                }

                BooleanQueryExpression booleanExpression = new BooleanQueryExpression
                {
                    Path     = expressionPath,
                    Operator = op,
                    Value    = (op != QueryOperator.Exists) ? new JValue(value) : null
                };

                if (_expression[_currentIndex] == ')')
                {
                    if (parentExpression != null)
                    {
                        parentExpression.Expressions.Add(booleanExpression);
                        return(rootExpression);
                    }

                    return(booleanExpression);
                }
                if (_expression[_currentIndex] == '&' && Match("&&"))
                {
                    if (parentExpression == null || parentExpression.Operator != QueryOperator.And)
                    {
                        CompositeExpression andExpression = new CompositeExpression {
                            Operator = QueryOperator.And
                        };

                        if (parentExpression != null)
                        {
                            parentExpression.Expressions.Add(andExpression);
                        }

                        parentExpression = andExpression;

                        if (rootExpression == null)
                        {
                            rootExpression = parentExpression;
                        }
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
                if (_expression[_currentIndex] == '|' && Match("||"))
                {
                    if (parentExpression == null || parentExpression.Operator != QueryOperator.Or)
                    {
                        CompositeExpression orExpression = new CompositeExpression {
                            Operator = QueryOperator.Or
                        };

                        if (parentExpression != null)
                        {
                            parentExpression.Expressions.Add(orExpression);
                        }

                        parentExpression = orExpression;

                        if (rootExpression == null)
                        {
                            rootExpression = parentExpression;
                        }
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
            }

            throw new JsonException("Path ended with open query.");
        }
示例#2
0
        private QueryExpression ParseExpression()
        {
            QueryExpression     rootExpression   = null;
            CompositeExpression parentExpression = null;

            while (_currentIndex < _expression.Length)
            {
                object left  = ParseSide();
                object right = null;

                QueryOperator op;
                if (_expression[_currentIndex] == ')' ||
                    _expression[_currentIndex] == '|' ||
                    _expression[_currentIndex] == '&')
                {
                    op = QueryOperator.Exists;
                }
                else
                {
                    op = ParseOperator();

                    right = ParseSide();
                }

                BooleanQueryExpression booleanExpression = new BooleanQueryExpression(op, left, right);

                if (_expression[_currentIndex] == ')')
                {
                    if (parentExpression != null)
                    {
                        parentExpression.Expressions.Add(booleanExpression);
                        return(rootExpression);
                    }

                    return(booleanExpression);
                }
                if (_expression[_currentIndex] == '&')
                {
                    if (!Match("&&"))
                    {
                        throw CreateUnexpectedCharacterException();
                    }

                    if (parentExpression == null || parentExpression.Operator != QueryOperator.And)
                    {
                        CompositeExpression andExpression = new CompositeExpression(QueryOperator.And);

                        parentExpression?.Expressions.Add(andExpression);

                        parentExpression = andExpression;

                        if (rootExpression == null)
                        {
                            rootExpression = parentExpression;
                        }
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
                if (_expression[_currentIndex] == '|')
                {
                    if (!Match("||"))
                    {
                        throw CreateUnexpectedCharacterException();
                    }

                    if (parentExpression == null || parentExpression.Operator != QueryOperator.Or)
                    {
                        CompositeExpression orExpression = new CompositeExpression(QueryOperator.Or);

                        parentExpression?.Expressions.Add(orExpression);

                        parentExpression = orExpression;

                        if (rootExpression == null)
                        {
                            rootExpression = parentExpression;
                        }
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
            }

            throw new JsonException("Path ended with open query.");
        }
示例#3
0
        public void BooleanExpressionTest()
        {
            BooleanQueryExpression e1 = new BooleanQueryExpression
            {
                Operator = QueryOperator.LessThan,
                Value = new JValue(3),
                Path = new List<PathFilter>
                {
                    new ArrayIndexFilter()
                }
            };

            Assert.IsTrue(e1.IsMatch(new JArray(1, 2, 3, 4, 5)));
            Assert.IsTrue(e1.IsMatch(new JArray(2, 3, 4, 5)));
            Assert.IsFalse(e1.IsMatch(new JArray(3, 4, 5)));
            Assert.IsFalse(e1.IsMatch(new JArray(4, 5)));

            BooleanQueryExpression e2 = new BooleanQueryExpression
            {
                Operator = QueryOperator.LessThanOrEquals,
                Value = new JValue(3),
                Path = new List<PathFilter>
                {
                    new ArrayIndexFilter()
                }
            };

            Assert.IsTrue(e2.IsMatch(new JArray(1, 2, 3, 4, 5)));
            Assert.IsTrue(e2.IsMatch(new JArray(2, 3, 4, 5)));
            Assert.IsTrue(e2.IsMatch(new JArray(3, 4, 5)));
            Assert.IsFalse(e2.IsMatch(new JArray(4, 5)));
        }
示例#4
0
        private QueryExpression ParseExpression()
        {
            QueryOperator       queryOperator;
            JValue              jValue;
            QueryExpression     queryExpression     = null;
            CompositeExpression compositeExpression = null;

            while (this._currentIndex < this._expression.Length)
            {
                this.EatWhitespace();
                if (this._expression[this._currentIndex] != '@')
                {
                    char chr = this._expression[this._currentIndex];
                    throw new JsonException(string.Concat("Unexpected character while parsing path query: ", chr.ToString()));
                }
                this._currentIndex++;
                List <PathFilter> pathFilters = new List <PathFilter>();
                if (this.ParsePath(pathFilters, this._currentIndex, true))
                {
                    throw new JsonException("Path ended with open query.");
                }
                this.EatWhitespace();
                this.EnsureLength("Path ended with open query.");
                object obj = null;
                if (this._expression[this._currentIndex] == ')' || this._expression[this._currentIndex] == '|' || this._expression[this._currentIndex] == '&')
                {
                    queryOperator = QueryOperator.Exists;
                }
                else
                {
                    queryOperator = this.ParseOperator();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                    obj = this.ParseValue();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                }
                BooleanQueryExpression booleanQueryExpression = new BooleanQueryExpression()
                {
                    Path     = pathFilters,
                    Operator = queryOperator
                };
                if (queryOperator != QueryOperator.Exists)
                {
                    jValue = new JValue(obj);
                }
                else
                {
                    jValue = null;
                }
                booleanQueryExpression.Value = jValue;
                BooleanQueryExpression booleanQueryExpression1 = booleanQueryExpression;
                if (this._expression[this._currentIndex] == ')')
                {
                    if (compositeExpression == null)
                    {
                        return(booleanQueryExpression1);
                    }
                    compositeExpression.Expressions.Add(booleanQueryExpression1);
                    return(queryExpression);
                }
                if (this._expression[this._currentIndex] == '&' && this.Match("&&"))
                {
                    if (compositeExpression == null || compositeExpression.Operator != QueryOperator.And)
                    {
                        CompositeExpression compositeExpression1 = new CompositeExpression()
                        {
                            Operator = QueryOperator.And
                        };
                        if (compositeExpression != null)
                        {
                            compositeExpression.Expressions.Add(compositeExpression1);
                        }
                        compositeExpression = compositeExpression1;
                        if (queryExpression == null)
                        {
                            queryExpression = compositeExpression;
                        }
                    }
                    compositeExpression.Expressions.Add(booleanQueryExpression1);
                }
                if (this._expression[this._currentIndex] != '|' || !this.Match("||"))
                {
                    continue;
                }
                if (compositeExpression == null || compositeExpression.Operator != QueryOperator.Or)
                {
                    CompositeExpression compositeExpression2 = new CompositeExpression()
                    {
                        Operator = QueryOperator.Or
                    };
                    if (compositeExpression != null)
                    {
                        compositeExpression.Expressions.Add(compositeExpression2);
                    }
                    compositeExpression = compositeExpression2;
                    if (queryExpression == null)
                    {
                        queryExpression = compositeExpression;
                    }
                }
                compositeExpression.Expressions.Add(booleanQueryExpression1);
            }
            throw new JsonException("Path ended with open query.");
        }
示例#5
0
        private bool MatchTokens(JToken leftResult, JToken rightResult)
        {
            JValue jValue  = leftResult as JValue;
            JValue jValue1 = jValue;

            if (jValue != null)
            {
                JValue jValue2 = rightResult as JValue;
                JValue jValue3 = jValue2;
                if (jValue2 == null)
                {
                    goto Label0;
                }
                switch (base.Operator)
                {
                case QueryOperator.Equals:
                {
                    if (!BooleanQueryExpression.EqualsWithStringCoercion(jValue1, jValue3))
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.NotEquals:
                {
                    if (BooleanQueryExpression.EqualsWithStringCoercion(jValue1, jValue3))
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.Exists:
                {
                    return(true);
                }

                case QueryOperator.LessThan:
                {
                    if (jValue1.CompareTo(jValue3) >= 0)
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.LessThanOrEquals:
                {
                    if (jValue1.CompareTo(jValue3) > 0)
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.GreaterThan:
                {
                    if (jValue1.CompareTo(jValue3) <= 0)
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.GreaterThanOrEquals:
                {
                    if (jValue1.CompareTo(jValue3) < 0)
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.RegexEquals:
                {
                    if (!BooleanQueryExpression.RegexEquals(jValue1, jValue3))
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.StrictEquals:
                {
                    if (!BooleanQueryExpression.EqualsWithStrictMatch(jValue1, jValue3))
                    {
                        break;
                    }
                    return(true);
                }

                case QueryOperator.StrictNotEquals:
                {
                    if (BooleanQueryExpression.EqualsWithStrictMatch(jValue1, jValue3))
                    {
                        break;
                    }
                    return(true);
                }
                }
            }
            else
            {
                goto Label0;
            }
            return(false);

Label0:
            if ((int)base.Operator - (int)QueryOperator.NotEquals <= (int)QueryOperator.Equals)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        private QueryExpression ParseExpression()
        {
            QueryExpression rootExpression = null;
            CompositeExpression parentExpression = null;

            while (_currentIndex < _expression.Length)
            {
                EatWhitespace();

                if (_expression[_currentIndex] != '@')
                    throw new JsonException("Unexpected character while parsing path query: " + _expression[_currentIndex]);

                _currentIndex++;

                List<PathFilter> expressionPath = new List<PathFilter>();

                if (ParsePath(expressionPath, _currentIndex, true))
                    throw new JsonException("Path ended with open query.");

                EatWhitespace();
                EnsureLength("Path ended with open query.");

                QueryOperator op;
                object value = null;
                if (_expression[_currentIndex] == ')'
                    || _expression[_currentIndex] == '|'
                    || _expression[_currentIndex] == '&')
                {
                    op = QueryOperator.Exists;
                }
                else
                {
                    op = ParseOperator();

                    EatWhitespace();
                    EnsureLength("Path ended with open query.");

                    value = ParseValue();

                    EatWhitespace();
                    EnsureLength("Path ended with open query.");
                }

                BooleanQueryExpression booleanExpression = new BooleanQueryExpression
                {
                    Path = expressionPath,
                    Operator = op,
                    Value = (op != QueryOperator.Exists) ? new JValue(value) : null
                };

                if (_expression[_currentIndex] == ')')
                {
                    if (parentExpression != null)
                    {
                        parentExpression.Expressions.Add(booleanExpression);
                        return rootExpression;
                    }
                    
                    return booleanExpression;
                }
                if (_expression[_currentIndex] == '&' && Match("&&"))
                {
                    if (parentExpression == null || parentExpression.Operator != QueryOperator.And)
                    {
                        CompositeExpression andExpression = new CompositeExpression { Operator = QueryOperator.And };

                        if (parentExpression != null)
                            parentExpression.Expressions.Add(andExpression);

                        parentExpression = andExpression;

                        if (rootExpression == null)
                            rootExpression = parentExpression;
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
                if (_expression[_currentIndex] == '|' && Match("||"))
                {
                    if (parentExpression == null || parentExpression.Operator != QueryOperator.Or)
                    {
                        CompositeExpression orExpression = new CompositeExpression { Operator = QueryOperator.Or };

                        if (parentExpression != null)
                            parentExpression.Expressions.Add(orExpression);

                        parentExpression = orExpression;

                        if (rootExpression == null)
                            rootExpression = parentExpression;
                    }

                    parentExpression.Expressions.Add(booleanExpression);
                }
            }

            throw new JsonException("Path ended with open query.");
        }
        // Token: 0x06001776 RID: 6006 RVA: 0x000724C4 File Offset: 0x000706C4
        private bool MatchTokens(JToken leftResult, JToken rightResult)
        {
            JValue jvalue = leftResult as JValue;

            if (jvalue != null)
            {
                JValue jvalue2 = rightResult as JValue;
                if (jvalue2 != null)
                {
                    switch (this.Operator)
                    {
                    case QueryOperator.Equals:
                        if (BooleanQueryExpression.EqualsWithStringCoercion(jvalue, jvalue2))
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.NotEquals:
                        if (!BooleanQueryExpression.EqualsWithStringCoercion(jvalue, jvalue2))
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.Exists:
                        return(true);

                    case QueryOperator.LessThan:
                        if (jvalue.CompareTo(jvalue2) < 0)
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.LessThanOrEquals:
                        if (jvalue.CompareTo(jvalue2) <= 0)
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.GreaterThan:
                        if (jvalue.CompareTo(jvalue2) > 0)
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.GreaterThanOrEquals:
                        if (jvalue.CompareTo(jvalue2) >= 0)
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.And:
                    case QueryOperator.Or:
                        return(false);

                    case QueryOperator.RegexEquals:
                        if (BooleanQueryExpression.RegexEquals(jvalue, jvalue2))
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.StrictEquals:
                        if (BooleanQueryExpression.EqualsWithStrictMatch(jvalue, jvalue2))
                        {
                            return(true);
                        }
                        return(false);

                    case QueryOperator.StrictNotEquals:
                        if (!BooleanQueryExpression.EqualsWithStrictMatch(jvalue, jvalue2))
                        {
                            return(true);
                        }
                        return(false);

                    default:
                        return(false);
                    }
                }
            }
            QueryOperator @operator = this.Operator;

            if (@operator - QueryOperator.NotEquals <= 1)
            {
                return(true);
            }
            return(false);
        }
示例#8
0
        private QueryExpression ParseExpression()
        {
            QueryOperator       queryOperator;
            QueryExpression     queryExpression     = null;
            CompositeExpression compositeExpression = null;

            while (this._currentIndex < this._expression.Length)
            {
                object obj  = this.ParseSide();
                object obj1 = null;
                if (this._expression[this._currentIndex] != ')' && this._expression[this._currentIndex] != '|')
                {
                    if (this._expression[this._currentIndex] == '&')
                    {
                        goto Label2;
                    }
                    queryOperator = this.ParseOperator();
                    obj1          = this.ParseSide();
                    goto Label0;
                }
Label2:
                queryOperator = QueryOperator.Exists;
Label0:
                BooleanQueryExpression booleanQueryExpression = new BooleanQueryExpression()
                {
                    Left     = obj,
                    Operator = queryOperator,
                    Right    = obj1
                };
                BooleanQueryExpression booleanQueryExpression1 = booleanQueryExpression;
                if (this._expression[this._currentIndex] == ')')
                {
                    if (compositeExpression == null)
                    {
                        return(booleanQueryExpression1);
                    }
                    compositeExpression.Expressions.Add(booleanQueryExpression1);
                    return(queryExpression);
                }
                if (this._expression[this._currentIndex] == '&')
                {
                    if (!this.Match("&&"))
                    {
                        throw this.CreateUnexpectedCharacterException();
                    }
                    if (compositeExpression == null || compositeExpression.Operator != QueryOperator.And)
                    {
                        CompositeExpression compositeExpression1 = new CompositeExpression()
                        {
                            Operator = QueryOperator.And
                        };
                        if (compositeExpression != null)
                        {
                            compositeExpression.Expressions.Add(compositeExpression1);
                        }
                        compositeExpression = compositeExpression1;
                        if (queryExpression == null)
                        {
                            queryExpression = compositeExpression;
                        }
                    }
                    compositeExpression.Expressions.Add(booleanQueryExpression1);
                }
                if (this._expression[this._currentIndex] != '|')
                {
                    continue;
                }
                if (!this.Match("||"))
                {
                    throw this.CreateUnexpectedCharacterException();
                }
                if (compositeExpression == null || compositeExpression.Operator != QueryOperator.Or)
                {
                    CompositeExpression compositeExpression2 = new CompositeExpression()
                    {
                        Operator = QueryOperator.Or
                    };
                    if (compositeExpression != null)
                    {
                        compositeExpression.Expressions.Add(compositeExpression2);
                    }
                    compositeExpression = compositeExpression2;
                    if (queryExpression == null)
                    {
                        queryExpression = compositeExpression;
                    }
                }
                compositeExpression.Expressions.Add(booleanQueryExpression1);
            }
            throw new JsonException("Path ended with open query.");
        }
示例#9
0
        private QueryExpression ParseExpression()
        {
            QueryExpression     queryExpression     = null;
            CompositeExpression compositeExpression = null;

            while (this._currentIndex < this._expression.Length)
            {
                this.EatWhitespace();
                if (this._expression[this._currentIndex] != '@')
                {
                    throw new JsonException("Unexpected character while parsing path query: " + this._expression[this._currentIndex]);
                }
                this._currentIndex++;
                List <PathFilter> list = new List <PathFilter>();
                if (this.ParsePath(list, this._currentIndex, true))
                {
                    throw new JsonException("Path ended with open query.");
                }
                this.EatWhitespace();
                this.EnsureLength("Path ended with open query.");
                object        value = null;
                QueryOperator queryOperator;
                if (this._expression[this._currentIndex] == ')' || this._expression[this._currentIndex] == '|' || this._expression[this._currentIndex] == '&')
                {
                    queryOperator = QueryOperator.Exists;
                }
                else
                {
                    queryOperator = this.ParseOperator();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                    value = this.ParseValue();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                }
                BooleanQueryExpression booleanQueryExpression = new BooleanQueryExpression
                {
                    Path     = list,
                    Operator = queryOperator,
                    Value    = (queryOperator != QueryOperator.Exists) ? new JValue(value) : null
                };
                if (this._expression[this._currentIndex] == ')')
                {
                    if (compositeExpression != null)
                    {
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                        return(queryExpression);
                    }
                    return(booleanQueryExpression);
                }
                else
                {
                    if (this._expression[this._currentIndex] == '&' && this.Match("&&"))
                    {
                        if (compositeExpression == null || compositeExpression.Operator != QueryOperator.And)
                        {
                            CompositeExpression compositeExpression2 = new CompositeExpression
                            {
                                Operator = QueryOperator.And
                            };
                            if (compositeExpression != null)
                            {
                                compositeExpression.Expressions.Add(compositeExpression2);
                            }
                            compositeExpression = compositeExpression2;
                            if (queryExpression == null)
                            {
                                queryExpression = compositeExpression;
                            }
                        }
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                    }
                    if (this._expression[this._currentIndex] == '|' && this.Match("||"))
                    {
                        if (compositeExpression == null || compositeExpression.Operator != QueryOperator.Or)
                        {
                            CompositeExpression compositeExpression3 = new CompositeExpression
                            {
                                Operator = QueryOperator.Or
                            };
                            if (compositeExpression != null)
                            {
                                compositeExpression.Expressions.Add(compositeExpression3);
                            }
                            compositeExpression = compositeExpression3;
                            if (queryExpression == null)
                            {
                                queryExpression = compositeExpression;
                            }
                        }
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                    }
                }
            }
            throw new JsonException("Path ended with open query.");
        }
示例#10
0
        private QueryExpression ParseExpression()
        {
            QueryExpression     expression  = null;
            CompositeExpression expression2 = null;

            while (this._currentIndex < this._expression.Length)
            {
                QueryOperator exists;
                this.EatWhitespace();
                if (this._expression[this._currentIndex] != '@')
                {
                    char ch = this._expression[this._currentIndex];
                    throw new JsonException("Unexpected character while parsing path query: " + ch.ToString());
                }
                this._currentIndex++;
                List <PathFilter> filters = new List <PathFilter>();
                if (this.ParsePath(filters, this._currentIndex, true))
                {
                    throw new JsonException("Path ended with open query.");
                }
                this.EatWhitespace();
                this.EnsureLength("Path ended with open query.");
                object obj2 = null;
                if (((this._expression[this._currentIndex] == ')') || (this._expression[this._currentIndex] == '|')) || (this._expression[this._currentIndex] == '&'))
                {
                    exists = QueryOperator.Exists;
                }
                else
                {
                    exists = this.ParseOperator();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                    obj2 = this.ParseValue();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                }
                BooleanQueryExpression item = new BooleanQueryExpression {
                    Path     = filters,
                    Operator = exists,
                    Value    = (exists != QueryOperator.Exists) ? new JValue(obj2) : null
                };
                if (this._expression[this._currentIndex] == ')')
                {
                    if (expression2 != null)
                    {
                        expression2.Expressions.Add(item);
                        return(expression);
                    }
                    return(item);
                }
                if ((this._expression[this._currentIndex] == '&') && this.Match("&&"))
                {
                    if ((expression2 == null) || (expression2.Operator != QueryOperator.And))
                    {
                        CompositeExpression expression4 = new CompositeExpression {
                            Operator = QueryOperator.And
                        };
                        if (expression2 != null)
                        {
                            expression2.Expressions.Add(expression4);
                        }
                        expression2 = expression4;
                        if (expression == null)
                        {
                            expression = expression2;
                        }
                    }
                    expression2.Expressions.Add(item);
                }
                if ((this._expression[this._currentIndex] == '|') && this.Match("||"))
                {
                    if ((expression2 == null) || (expression2.Operator != QueryOperator.Or))
                    {
                        CompositeExpression expression5 = new CompositeExpression {
                            Operator = QueryOperator.Or
                        };
                        if (expression2 != null)
                        {
                            expression2.Expressions.Add(expression5);
                        }
                        expression2 = expression5;
                        if (expression == null)
                        {
                            expression = expression2;
                        }
                    }
                    expression2.Expressions.Add(item);
                }
            }
            throw new JsonException("Path ended with open query.");
        }
示例#11
0
文件: JPath.cs 项目: zha0/Cerberus
        // Token: 0x0600145A RID: 5210 RVA: 0x0006BA30 File Offset: 0x00069C30
        private QueryExpression ParseExpression()
        {
            QueryExpression     queryExpression     = null;
            CompositeExpression compositeExpression = null;

            while (this._currentIndex < this._expression.Length)
            {
                object        left  = this.ParseSide();
                object        right = null;
                QueryOperator @operator;
                if (this._expression[this._currentIndex] == ')' || this._expression[this._currentIndex] == '|' || this._expression[this._currentIndex] == '&')
                {
                    @operator = QueryOperator.Exists;
                }
                else
                {
                    @operator = this.ParseOperator();
                    right     = this.ParseSide();
                }
                BooleanQueryExpression booleanQueryExpression = new BooleanQueryExpression(@operator, left, right);
                if (this._expression[this._currentIndex] == ')')
                {
                    if (compositeExpression != null)
                    {
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                        return(queryExpression);
                    }
                    return(booleanQueryExpression);
                }
                else
                {
                    if (this._expression[this._currentIndex] == '&')
                    {
                        if (!this.Match("&&"))
                        {
                            throw this.CreateUnexpectedCharacterException();
                        }
                        if (compositeExpression == null || compositeExpression.Operator != QueryOperator.And)
                        {
                            CompositeExpression compositeExpression2 = new CompositeExpression(QueryOperator.And);
                            if (compositeExpression != null)
                            {
                                compositeExpression.Expressions.Add(compositeExpression2);
                            }
                            compositeExpression = compositeExpression2;
                            if (queryExpression == null)
                            {
                                queryExpression = compositeExpression;
                            }
                        }
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                    }
                    if (this._expression[this._currentIndex] == '|')
                    {
                        if (!this.Match("||"))
                        {
                            throw this.CreateUnexpectedCharacterException();
                        }
                        if (compositeExpression == null || compositeExpression.Operator != QueryOperator.Or)
                        {
                            CompositeExpression compositeExpression3 = new CompositeExpression(QueryOperator.Or);
                            if (compositeExpression != null)
                            {
                                compositeExpression.Expressions.Add(compositeExpression3);
                            }
                            compositeExpression = compositeExpression3;
                            if (queryExpression == null)
                            {
                                queryExpression = compositeExpression;
                            }
                        }
                        compositeExpression.Expressions.Add(booleanQueryExpression);
                    }
                }
            }
            throw new JsonException("Path ended with open query.");
        }
示例#12
0
 // Token: 0x0600024D RID: 589
 // RVA: 0x0002DFF8 File Offset: 0x0002C1F8
 private QueryExpression ParseExpression()
 {
     QueryExpression queryExpression = null;
     CompositeExpression compositeExpression = null;
     while (this._currentIndex < this._expression.Length)
     {
         this.EatWhitespace();
         if (this._expression[this._currentIndex] != '@')
         {
             throw new JsonException("Unexpected character while parsing path query: " + this._expression[this._currentIndex]);
         }
         this._currentIndex++;
         List<PathFilter> list = new List<PathFilter>();
         if (!this.ParsePath(list, this._currentIndex, true))
         {
             this.EatWhitespace();
             this.EnsureLength("Path ended with open query.");
             object value = null;
             if (this._expression[this._currentIndex] == ')' || this._expression[this._currentIndex] == '|')
             {
                 goto IL_D8;
             }
             if (this._expression[this._currentIndex] == '&')
             {
                 goto IL_D8;
             }
             QueryOperator queryOperator = this.ParseOperator();
             this.EatWhitespace();
             this.EnsureLength("Path ended with open query.");
             value = this.ParseValue();
             this.EatWhitespace();
             this.EnsureLength("Path ended with open query.");
             IL_DA:
             BooleanQueryExpression booleanQueryExpression = new BooleanQueryExpression
             {
                 Path = list,
                 Operator = queryOperator,
                 Value = ((queryOperator != QueryOperator.Exists) ? new JValue(value) : null)
             };
             if (this._expression[this._currentIndex] == ')')
             {
                 if (compositeExpression != null)
                 {
                     compositeExpression.Expressions.Add(booleanQueryExpression);
                     return queryExpression;
                 }
                 return booleanQueryExpression;
             }
             else
             {
                 if (this._expression[this._currentIndex] == '&' && this.Match("&&"))
                 {
                     if (compositeExpression == null || compositeExpression.Operator != QueryOperator.And)
                     {
                         CompositeExpression compositeExpression2 = new CompositeExpression
                         {
                             Operator = QueryOperator.And
                         };
                         if (compositeExpression != null)
                         {
                             compositeExpression.Expressions.Add(compositeExpression2);
                         }
                         compositeExpression = compositeExpression2;
                         if (queryExpression == null)
                         {
                             queryExpression = compositeExpression;
                         }
                     }
                     compositeExpression.Expressions.Add(booleanQueryExpression);
                 }
                 if (this._expression[this._currentIndex] == '|' && this.Match("||"))
                 {
                     if (compositeExpression == null || compositeExpression.Operator != QueryOperator.Or)
                     {
                         CompositeExpression compositeExpression3 = new CompositeExpression
                         {
                             Operator = QueryOperator.Or
                         };
                         if (compositeExpression != null)
                         {
                             compositeExpression.Expressions.Add(compositeExpression3);
                         }
                         compositeExpression = compositeExpression3;
                         if (queryExpression == null)
                         {
                             queryExpression = compositeExpression;
                         }
                     }
                     compositeExpression.Expressions.Add(booleanQueryExpression);
                     continue;
                 }
                 continue;
             }
             IL_D8:
             queryOperator = QueryOperator.Exists;
             goto IL_DA;
         }
         throw new JsonException("Path ended with open query.");
     }
     throw new JsonException("Path ended with open query.");
 }
示例#13
0
        private QueryExpression ParseExpression()
        {
            QueryExpression     queryExpression      = (QueryExpression)null;
            CompositeExpression compositeExpression1 = (CompositeExpression)null;

            while (this._currentIndex < this._expression.Length)
            {
                this.EatWhitespace();
                if (this._expression[this._currentIndex] != '@')
                {
                    throw new JsonException("Unexpected character while parsing path query: " + this._expression[this._currentIndex].ToString());
                }
                ++this._currentIndex;
                List <PathFilter> filters = new List <PathFilter>();
                if (this.ParsePath(filters, this._currentIndex, true))
                {
                    throw new JsonException("Path ended with open query.");
                }
                this.EatWhitespace();
                this.EnsureLength("Path ended with open query.");
                object        obj = (object)null;
                QueryOperator queryOperator;
                if (this._expression[this._currentIndex] == ')' || this._expression[this._currentIndex] == '|' || this._expression[this._currentIndex] == '&')
                {
                    queryOperator = QueryOperator.Exists;
                }
                else
                {
                    queryOperator = this.ParseOperator();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                    obj = this.ParseValue();
                    this.EatWhitespace();
                    this.EnsureLength("Path ended with open query.");
                }
                BooleanQueryExpression booleanQueryExpression1 = new BooleanQueryExpression();
                booleanQueryExpression1.Path     = filters;
                booleanQueryExpression1.Operator = queryOperator;
                booleanQueryExpression1.Value    = queryOperator != QueryOperator.Exists ? new JValue(obj) : (JValue)null;
                BooleanQueryExpression booleanQueryExpression2 = booleanQueryExpression1;
                if (this._expression[this._currentIndex] == ')')
                {
                    if (compositeExpression1 == null)
                    {
                        return((QueryExpression)booleanQueryExpression2);
                    }
                    compositeExpression1.Expressions.Add((QueryExpression)booleanQueryExpression2);
                    return(queryExpression);
                }
                if (this._expression[this._currentIndex] == '&' && this.Match("&&"))
                {
                    if (compositeExpression1 == null || compositeExpression1.Operator != QueryOperator.And)
                    {
                        CompositeExpression compositeExpression2 = new CompositeExpression();
                        compositeExpression2.Operator = QueryOperator.And;
                        CompositeExpression compositeExpression3 = compositeExpression2;
                        compositeExpression1?.Expressions.Add((QueryExpression)compositeExpression3);
                        compositeExpression1 = compositeExpression3;
                        if (queryExpression == null)
                        {
                            queryExpression = (QueryExpression)compositeExpression1;
                        }
                    }
                    compositeExpression1.Expressions.Add((QueryExpression)booleanQueryExpression2);
                }
                if (this._expression[this._currentIndex] == '|' && this.Match("||"))
                {
                    if (compositeExpression1 == null || compositeExpression1.Operator != QueryOperator.Or)
                    {
                        CompositeExpression compositeExpression2 = new CompositeExpression();
                        compositeExpression2.Operator = QueryOperator.Or;
                        CompositeExpression compositeExpression3 = compositeExpression2;
                        compositeExpression1?.Expressions.Add((QueryExpression)compositeExpression3);
                        compositeExpression1 = compositeExpression3;
                        if (queryExpression == null)
                        {
                            queryExpression = (QueryExpression)compositeExpression1;
                        }
                    }
                    compositeExpression1.Expressions.Add((QueryExpression)booleanQueryExpression2);
                }
            }
            throw new JsonException("Path ended with open query.");
        }