Exemple #1
0
        /// <summary>
        /// Returns a collection of the descendant tokens for this token in document order.
        /// </summary>
        /// <returns>An <see cref="IEnumerable{JToken}"/> containing the descendant tokens of the <see cref="JToken"/>.</returns>
        public IEnumerable <JToken> Descendants()
        {
            foreach (JToken o in ChildrenTokens)
            {
                yield return(o);

                JContainer c = o as JContainer;
                if (c != null)
                {
                    foreach (JToken d in c.Descendants())
                    {
                        yield return(d);
                    }
                }
            }
        }
Exemple #2
0
        internal IEnumerable<JToken> GetDescendants(bool self)
        {
            if (self)
            {
                yield return this;
            }

            foreach (JToken o in ChildrenTokens)
            {
                yield return o;
                JContainer c = o as JContainer;
                if (c != null)
                {
                    foreach (JToken d in c.Descendants())
                    {
                        yield return d;
                    }
                }
            }
        }