GetTokenIndex() protected static method

protected static GetTokenIndex ( JToken t, bool errorWhenNoMatch, int index ) : JToken
t JToken
errorWhenNoMatch bool
index int
return JToken
Beispiel #1
0
 public override IEnumerable <JToken> ExecuteFilter(IEnumerable <JToken> current, bool errorWhenNoMatch)
 {
     foreach (JToken current2 in current)
     {
         if (this.Index.HasValue)
         {
             JToken tokenIndex = PathFilter.GetTokenIndex(current2, errorWhenNoMatch, this.Index.Value);
             if (tokenIndex != null)
             {
                 yield return(tokenIndex);
             }
         }
         else if (current2 is JArray || current2 is JConstructor)
         {
             foreach (JToken current3 in ((IEnumerable <JToken>)current2))
             {
                 yield return(current3);
             }
         }
         else if (errorWhenNoMatch)
         {
             throw new JsonException("Index * not valid on {0}.".FormatWith(CultureInfo.InvariantCulture, current2.GetType().Name));
         }
     }
     yield break;
 }
Beispiel #2
0
        public override IEnumerable <JToken> ExecuteFilter(JToken root, IEnumerable <JToken> current, bool errorWhenNoMatch)
        {
            foreach (JToken jtoken in current)
            {
                if (this.Index != null)
                {
                    JToken tokenIndex = PathFilter.GetTokenIndex(jtoken, errorWhenNoMatch, this.Index.GetValueOrDefault());
                    if (tokenIndex != null)
                    {
                        yield return(tokenIndex);
                    }
                }
                else if (jtoken is JArray || jtoken is JConstructor)
                {
                    foreach (JToken jtoken2 in ((IEnumerable <JToken>)jtoken))
                    {
                        yield return(jtoken2);
                    }
                    IEnumerator <JToken> enumerator2 = null;
                }
                else if (errorWhenNoMatch)
                {
                    throw new JsonException("Index * not valid on {0}.".FormatWith(CultureInfo.InvariantCulture, jtoken.GetType().Name));
                }
            }
            IEnumerator <JToken> enumerator = null;

            yield break;
            yield break;
        }
 public override IEnumerable <JToken> ExecuteFilter(
     IEnumerable <JToken> current,
     bool errorWhenNoMatch)
 {
     foreach (JToken jtoken1 in current)
     {
         JToken t = jtoken1;
         if (this.Index.HasValue)
         {
             JToken tokenIndex = PathFilter.GetTokenIndex(t, errorWhenNoMatch, this.Index.GetValueOrDefault());
             if (tokenIndex != null)
             {
                 yield return(tokenIndex);
             }
         }
         else if (t is JArray || t is JConstructor)
         {
             foreach (JToken jtoken2 in (IEnumerable <JToken>)t)
             {
                 yield return(jtoken2);
             }
         }
         else if (errorWhenNoMatch)
         {
             throw new JsonException("Index * not valid on {0}.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)t.GetType().Name));
         }
         t = (JToken)null;
     }
 }
Beispiel #4
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);
         }
     }
 }
 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;
 }
Beispiel #6
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;
        }
        // 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;
        }