Exemplo n.º 1
0
        /// <summary>
        /// Helper function to easily extract a list of objects of type T from a UIHierarchy tree.
        /// </summary>
        /// <typeparam name="T">The type of object to find in the tree. Extracts everything that "Is a" T.</typeparam>
        /// <param name="RootItem">The root of the UIHierarchy to search (converted to UITreeItem via GetUIHierarchyTree())</param>
        /// <returns>An enumerable of objects of type T found beneath the root item.</returns>
        public static IEnumerable <T> GetUITreeItemObjectsByType <T>(UITreeItem RootItem) where T : class
        {
            List <T> Results = new List <T>();

            if (RootItem.Object is T)
            {
                Results.Add((T)RootItem.Object);
            }
            foreach (var Child in RootItem.Children)
            {
                Results.AddRange(GetUITreeItemObjectsByType <T>(Child));
            }

            return(Results);
        }
Exemplo n.º 2
0
        public static IEnumerable <UIHierarchyItem> GetUITreeItemsByObjectType <T>(UITreeItem RootItem) where T : class
        {
            List <UIHierarchyItem> Results = new List <UIHierarchyItem>();

            if (RootItem.Object is T)
            {
                Results.Add(RootItem.Item);
            }
            foreach (var Child in RootItem.Children)
            {
                Results.AddRange(GetUITreeItemsByObjectType <T>(Child));
            }

            return(Results);
        }