public override IEnumerable <JToken> ExecuteFilter(IEnumerable <JToken> current, bool errorWhenNoMatch)
 {
     foreach (JToken current2 in current)
     {
         foreach (int current3 in this.Indexes)
         {
             JToken tokenIndex = PathFilter.GetTokenIndex(current2, errorWhenNoMatch, current3);
             if (tokenIndex != null)
             {
                 yield return(tokenIndex);
             }
         }
     }
     yield break;
 }
Exemplo n.º 2
0
 public override IEnumerable <JToken> ExecuteFilter(IEnumerable <JToken> current, bool errorWhenNoMatch)
 {
     foreach (JToken jTokens in current)
     {
         foreach (int index in this.Indexes)
         {
             JToken tokenIndex = PathFilter.GetTokenIndex(jTokens, errorWhenNoMatch, index);
             if (tokenIndex == null)
             {
                 continue;
             }
             yield return(tokenIndex);
         }
     }
 }
Exemplo n.º 3
0
        public override IEnumerable <JToken> ExecuteFilter(IEnumerable <JToken> current, bool errorWhenNoMatch)
        {
            JToken jTokens;

            using (IEnumerator <JToken> enumerator = current.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    jTokens = enumerator.Current;
                    if (this.Index.HasValue)
                    {
                        JToken jTokens1   = jTokens;
                        bool   flag       = errorWhenNoMatch;
                        int?   index      = this.Index;
                        JToken tokenIndex = PathFilter.GetTokenIndex(jTokens1, flag, index.GetValueOrDefault());
                        if (tokenIndex != null)
                        {
                            yield return(tokenIndex);
                        }
                    }
                    else if (jTokens is JArray || jTokens is JConstructor)
                    {
                        using (IEnumerator <JToken> enumerator1 = ((IEnumerable <JToken>)jTokens).GetEnumerator())
                        {
                            while (enumerator1.MoveNext())
                            {
                                yield return(enumerator1.Current);
                            }
                        }
                        enumerator1 = null;
                    }
                    else if (errorWhenNoMatch)
                    {
                        throw new JsonException("Index * not valid on {0}.".FormatWith(CultureInfo.InvariantCulture, jTokens.GetType().Name));
                    }
                    jTokens = null;
                }
                goto Label1;
                throw new JsonException("Index * not valid on {0}.".FormatWith(CultureInfo.InvariantCulture, jTokens.GetType().Name));
            }
Label1:
            enumerator = null;
        }
Exemplo n.º 4
0
        // Token: 0x06001440 RID: 5184 RVA: 0x0006AE90 File Offset: 0x00069090
        public override IEnumerable <JToken> ExecuteFilter(JToken root, IEnumerable <JToken> current, bool errorWhenNoMatch)
        {
            foreach (JToken t in current)
            {
                foreach (int index in this.Indexes)
                {
                    JToken tokenIndex = PathFilter.GetTokenIndex(t, errorWhenNoMatch, index);
                    if (tokenIndex != null)
                    {
                        yield return(tokenIndex);
                    }
                }
                List <int> .Enumerator enumerator2 = default(List <int> .Enumerator);
                t = null;
            }
            IEnumerator <JToken> enumerator = null;

            yield break;
            yield break;
        }
Exemplo n.º 5
0
        public override IEnumerable <JToken> ExecuteFilter(JToken root, IEnumerable <JToken> current, bool errorWhenNoMatch)
        {
            foreach (JToken c in current)
            {
                if (this.Name == null)
                {
                    yield return(c);
                }
                JToken value = c;
                for (;;)
                {
                    JContainer container = value as JContainer;
                    value = PathFilter.GetNextScanValue(c, container, value);
                    if (value == null)
                    {
                        break;
                    }
                    JProperty jproperty = value as JProperty;
                    if (jproperty != null)
                    {
                        if (jproperty.Name == this.Name)
                        {
                            yield return(jproperty.Value);
                        }
                    }
                    else if (this.Name == null)
                    {
                        yield return(value);
                    }
                }
                value = null;
                c     = null;
            }
            IEnumerator <JToken> enumerator = null;

            yield break;
            yield break;
        }
Exemplo n.º 6
0
        private static PathFilter CreatePathFilter(string member, bool scan)
        {
            PathFilter filter = (scan) ? (PathFilter) new ScanFilter(member) : new FieldFilter(member);

            return(filter);
        }
Exemplo n.º 7
0
        private bool ParsePath(List <PathFilter> filters, int currentPartStartIndex, bool query)
        {
            bool scan             = false;
            bool followingIndexer = false;
            bool followingDot     = false;

            bool ended = false;

            while (_currentIndex < _expression.Length && !ended)
            {
                char currentChar = _expression[_currentIndex];

                switch (currentChar)
                {
                case '[':
                case '(':
                    if (_currentIndex > currentPartStartIndex)
                    {
                        string     member = _expression.Substring(currentPartStartIndex, _currentIndex - currentPartStartIndex);
                        PathFilter filter = (scan) ? (PathFilter) new ScanFilter()
                        {
                            Name = member
                        } : new FieldFilter()
                        {
                            Name = member
                        };
                        filters.Add(filter);
                        scan = false;
                    }

                    filters.Add(ParseIndexer(currentChar));
                    _currentIndex++;
                    currentPartStartIndex = _currentIndex;
                    followingIndexer      = true;
                    followingDot          = false;
                    break;

                case ']':
                case ')':
                    ended = true;
                    break;

                case ' ':
                    //EatWhitespace();
                    if (_currentIndex < _expression.Length)
                    {
                        ended = true;
                    }
                    break;

                case '.':
                    if (_currentIndex > currentPartStartIndex)
                    {
                        string member = _expression.Substring(currentPartStartIndex, _currentIndex - currentPartStartIndex);
                        if (member == "*")
                        {
                            member = null;
                        }
                        PathFilter filter = (scan) ? (PathFilter) new ScanFilter()
                        {
                            Name = member
                        } : new FieldFilter()
                        {
                            Name = member
                        };
                        filters.Add(filter);
                        scan = false;
                    }
                    if (_currentIndex + 1 < _expression.Length && _expression[_currentIndex + 1] == '.')
                    {
                        scan = true;
                        _currentIndex++;
                    }
                    _currentIndex++;
                    currentPartStartIndex = _currentIndex;
                    followingIndexer      = false;
                    followingDot          = true;
                    break;

                default:
                    if (query && (currentChar == '=' || currentChar == '<' || currentChar == '!' || currentChar == '>' || currentChar == '|' || currentChar == '&'))
                    {
                        ended = true;
                    }
                    else
                    {
                        if (followingIndexer)
                        {
                            throw new JsonException("Unexpected character following indexer: " + currentChar);
                        }

                        _currentIndex++;
                    }
                    break;
                }
            }

            bool atPathEnd = (_currentIndex == _expression.Length);

            if (_currentIndex > currentPartStartIndex)
            {
                string member = _expression.Substring(currentPartStartIndex, _currentIndex - currentPartStartIndex).TrimEnd();
                if (member == "*")
                {
                    member = null;
                }
                PathFilter filter = (scan) ? (PathFilter) new ScanFilter()
                {
                    Name = member
                } : new FieldFilter()
                {
                    Name = member
                };
                filters.Add(filter);
            }
            else
            {
                // no field name following dot in path and at end of base path/query
                if (followingDot && (atPathEnd || query))
                {
                    throw new JsonException("Unexpected end while parsing path.");
                }
            }

            return(atPathEnd);
        }
Exemplo n.º 8
0
        private bool ParsePath(List <PathFilter> filters, int currentPartStartIndex, bool query)
        {
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;

            while ((this._currentIndex < this._expression.Length) && !flag4)
            {
                char indexerOpenChar = this._expression[this._currentIndex];
                switch (indexerOpenChar)
                {
                case '.':
                {
                    if (this._currentIndex > currentPartStartIndex)
                    {
                        string str2 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                        if (str2 == "*")
                        {
                            str2 = null;
                        }
                        PathFilter item = flag ? ((PathFilter) new ScanFilter()) : ((PathFilter) new FieldFilter());
                        filters.Add(item);
                        flag = false;
                    }
                    if (((this._currentIndex + 1) < this._expression.Length) && (this._expression[this._currentIndex + 1] == '.'))
                    {
                        flag = true;
                        this._currentIndex++;
                    }
                    this._currentIndex++;
                    currentPartStartIndex = this._currentIndex;
                    flag2 = false;
                    flag3 = true;
                    continue;
                }

                case '[':
                case '(':
                {
                    if (this._currentIndex > currentPartStartIndex)
                    {
                        string str = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                        if (str == "*")
                        {
                            str = null;
                        }
                        PathFilter item = flag ? ((PathFilter) new ScanFilter()) : ((PathFilter) new FieldFilter());
                        filters.Add(item);
                        flag = false;
                    }
                    filters.Add(this.ParseIndexer(indexerOpenChar));
                    this._currentIndex++;
                    currentPartStartIndex = this._currentIndex;
                    flag2 = true;
                    flag3 = false;
                    continue;
                }

                case ']':
                case ')':
                {
                    flag4 = true;
                    continue;
                }

                case ' ':
                {
                    if (this._currentIndex < this._expression.Length)
                    {
                        flag4 = true;
                    }
                    continue;
                }
                }
                if (query && ((((indexerOpenChar == '=') || (indexerOpenChar == '<')) || ((indexerOpenChar == '!') || (indexerOpenChar == '>'))) || ((indexerOpenChar == '|') || (indexerOpenChar == '&'))))
                {
                    flag4 = true;
                }
                else
                {
                    if (flag2)
                    {
                        throw new JsonException("Unexpected character following indexer: " + indexerOpenChar.ToString());
                    }
                    this._currentIndex++;
                }
            }
            bool flag5 = this._currentIndex == this._expression.Length;

            if (this._currentIndex > currentPartStartIndex)
            {
                string str3 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex).TrimEnd(new char[0]);
                if (str3 == "*")
                {
                    str3 = null;
                }
                PathFilter item = flag ? ((PathFilter) new ScanFilter()) : ((PathFilter) new FieldFilter());
                filters.Add(item);
                return(flag5);
            }
            if (flag3 && (flag5 | query))
            {
                throw new JsonException("Unexpected end while parsing path.");
            }
            return(flag5);
        }
Exemplo n.º 9
0
        private bool ParsePath(List <PathFilter> filters, int currentPartStartIndex, bool query)
        {
            bool flag1 = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;

            while (this._currentIndex < this._expression.Length && !flag4)
            {
                char indexerOpenChar = this._expression[this._currentIndex];
                switch (indexerOpenChar)
                {
                case ' ':
                    if (this._currentIndex < this._expression.Length)
                    {
                        flag4 = true;
                        continue;
                    }
                    continue;

                case '(':
                case '[':
                    if (this._currentIndex > currentPartStartIndex)
                    {
                        string str = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                        if (str == "*")
                        {
                            str = (string)null;
                        }
                        PathFilter pathFilter1;
                        if (!flag1)
                        {
                            pathFilter1 = (PathFilter) new FieldFilter()
                            {
                                Name = str
                            };
                        }
                        else
                        {
                            pathFilter1 = (PathFilter) new ScanFilter();
                            ((ScanFilter)pathFilter1).Name = str;
                        }
                        PathFilter pathFilter2 = pathFilter1;
                        filters.Add(pathFilter2);
                        flag1 = false;
                    }
                    filters.Add(this.ParseIndexer(indexerOpenChar));
                    ++this._currentIndex;
                    currentPartStartIndex = this._currentIndex;
                    flag2 = true;
                    flag3 = false;
                    continue;

                case ')':
                case ']':
                    flag4 = true;
                    continue;

                case '.':
                    if (this._currentIndex > currentPartStartIndex)
                    {
                        string str = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                        if (str == "*")
                        {
                            str = (string)null;
                        }
                        PathFilter pathFilter1;
                        if (!flag1)
                        {
                            pathFilter1 = (PathFilter) new FieldFilter()
                            {
                                Name = str
                            };
                        }
                        else
                        {
                            pathFilter1 = (PathFilter) new ScanFilter();
                            ((ScanFilter)pathFilter1).Name = str;
                        }
                        PathFilter pathFilter2 = pathFilter1;
                        filters.Add(pathFilter2);
                        flag1 = false;
                    }
                    if (this._currentIndex + 1 < this._expression.Length && this._expression[this._currentIndex + 1] == '.')
                    {
                        flag1 = true;
                        ++this._currentIndex;
                    }
                    ++this._currentIndex;
                    currentPartStartIndex = this._currentIndex;
                    flag2 = false;
                    flag3 = true;
                    continue;

                default:
                    if (query && (indexerOpenChar == '=' || indexerOpenChar == '<' || (indexerOpenChar == '!' || indexerOpenChar == '>') || (indexerOpenChar == '|' || indexerOpenChar == '&')))
                    {
                        flag4 = true;
                        continue;
                    }
                    if (flag2)
                    {
                        throw new JsonException("Unexpected character following indexer: " + indexerOpenChar.ToString());
                    }
                    ++this._currentIndex;
                    continue;
                }
            }
            bool flag5 = this._currentIndex == this._expression.Length;

            if (this._currentIndex > currentPartStartIndex)
            {
                string str = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex).TrimEnd();
                if (str == "*")
                {
                    str = (string)null;
                }
                PathFilter pathFilter1;
                if (!flag1)
                {
                    pathFilter1 = (PathFilter) new FieldFilter()
                    {
                        Name = str
                    };
                }
                else
                {
                    pathFilter1 = (PathFilter) new ScanFilter();
                    ((ScanFilter)pathFilter1).Name = str;
                }
                PathFilter pathFilter2 = pathFilter1;
                filters.Add(pathFilter2);
            }
            else if (flag3 && flag5 | query)
            {
                throw new JsonException("Unexpected end while parsing path.");
            }
            return(flag5);
        }