Beispiel #1
0
        public static void Visit <T>(this ITreeEnumeratorAdvisor <T> iteratorAdvisor, IEnumerator <T> treeItemsEnumerator, Action <T, AncestorsEnumerator <T> > visitor) where T : class
        {
            using var enumerator = TreeEnumerator.GetEnumerator(treeItemsEnumerator, iteratorAdvisor);

            while (enumerator.MoveNext())
            {
                visitor(enumerator.Current, enumerator.CurrentAncestors);
            }
        }
Beispiel #2
0
        public static void Visit <T>(this ITreeEnumeratorAdvisor <T> iteratorAdvisor, T root, Action <T> visitor) where T : class
        {
            using var enumerator = TreeEnumerator.GetEnumerator(root, iteratorAdvisor);

            while (enumerator.MoveNext())
            {
                visitor(enumerator.Current);
            }
        }
Beispiel #3
0
        internal void Verify()
        {
            var treeFlatCountAdvisor        = new DelegateTreeEnumeratorAdvisor <TNode>(n => n.Nodes?.GetEnumerator() ?? Enumerable.Empty <TNode>().GetEnumerator());
            var treeVisibleFlatCountAdvisor = new DelegateTreeEnumeratorAdvisor <TNode>(n => n.IsExpanded ? n.Nodes.GetEnumerator() : Enumerable.Empty <TNode>().GetEnumerator());

            var flatCount = Nodes != null?TreeEnumerator.GetEnumerator(Nodes, treeFlatCountAdvisor).Enumerate().Count() : 0;

            var visibleCount = IsExpanded ? TreeEnumerator.GetEnumerator(Nodes, treeVisibleFlatCountAdvisor).Enumerate().Count() : 0;

            if (FlatCount != flatCount)
            {
                throw new Exception(nameof(FlatCount));
            }

            if (VisibleFlatCount != visibleCount)
            {
                throw new Exception(nameof(VisibleFlatCount));
            }
        }
Beispiel #4
0
 internal IEnumerable <KeyValuePair <string, object> > Flatten()
 {
     return(TreeEnumerator.GetEnumerator(this, ResourceTreeAdvisor).Enumerate());
 }
Beispiel #5
0
 public static ITreeEnumerator <T> GetEnumerator <T>(this ITreeEnumeratorAdvisor <T> advisor, IEnumerator <T> treeItemsEnumerator) where T : class
 {
     return(TreeEnumerator.GetEnumerator(treeItemsEnumerator, advisor));
 }
Beispiel #6
0
 public static ITreeEnumerator <T> GetEnumerator <T>(this ITreeEnumeratorAdvisor <T> advisor, T root) where T : class
 {
     return(TreeEnumerator.GetEnumerator(root, advisor));
 }