Пример #1
0
        /// <summary>
        /// Descendants iterator
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        private static IEnumerable <TokenSequence> DescendantsIterator(TokenSequence source)
        {
            if (ModelSubsequencer.IsPrimitive(source))
            {
                yield break;
            }

            if (ModelSubsequencer.IsObject(source))
            {
                foreach (KeyValuePair <DataName, TokenSequence> property in ModelSubsequencer.Properties(source, null))
                {
                    yield return(property.Value);

                    foreach (TokenSequence descendant in ModelSubsequencer.Descendants(property.Value))
                    {
                        yield return(descendant);
                    }
                }
                yield break;
            }

            if (ModelSubsequencer.IsArray(source))
            {
                foreach (TokenSequence item in ModelSubsequencer.ArrayItems(source, null))
                {
                    yield return(item);

                    foreach (TokenSequence descendant in ModelSubsequencer.Descendants(item))
                    {
                        yield return(descendant);
                    }
                }
                yield break;
            }
        }
Пример #2
0
 /// <summary>
 /// Gets all the items of the array
 /// </summary>
 /// <param name="source"></param>
 /// <returns>all items of the array</returns>
 public static IEnumerable <TokenSequence> ArrayItems(this TokenSequence source)
 {
     return(ModelSubsequencer.ArrayItems(source, null));
 }