예제 #1
0
        public static IEnumerable <TreeNodeObject> EnumerateTreeNodeObjects(TreeNodeObject root = null)
        {
            var roots = ListPool <TreeNodeObject> .Get();

            if (root != null)
            {
                roots.Add(root);
            }
            else
            {
                root = StudioAPI.GetSelectedObjects().FirstOrDefault()?.treeNodeObject;
                if (root != null)
                {
                    roots.AddRange(root.GetTreeNodeCtrl().GetTreeNodeObjects());
                }
            }

            foreach (var entry in roots)
            {
                yield return(entry);

                foreach (var tnObj in entry.child.SelectMany(EnumerateTreeNodeObjects))
                {
                    yield return(tnObj);
                }
            }

            ListPool <TreeNodeObject> .Release(roots);
        }
예제 #2
0
        private IEnumerable <TreeNodeObject> EnumerateTreeNodeObjects(TreeNodeObject root = null)
        {
            var roots = new List <TreeNodeObject>();

            if (root != null)
            {
                roots.Add(root);
            }
            else
            {
                root = StudioAPI.GetSelectedObjects().FirstOrDefault()?.treeNodeObject;
                if (root != null)
                {
                    roots.AddRange(root.GetTreeNodeCtrl().GetTreeNodeObjects());
                }
            }

            foreach (var entry in roots)
            {
                yield return(entry);

                foreach (var tnObj in entry.child.SelectMany(EnumerateTreeNodeObjects))
                {
                    yield return(tnObj);
                }
            }
            roots.Clear();
        }