Esempio n. 1
0
        /// <summary>
        /// Gets the outline item and its ancestors scene.
        /// </summary>
        /// <param name="item">The outline item.</param>
        /// <returns>The <paramref name="item"/> and its ancestors of the scene.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="item"/> is <see langword="null"/>.
        /// </exception>
        public static IEnumerable <OutlineItem> GetSelfAndAncestors(this OutlineItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            return(TreeHelper.GetSelfAndAncestors(item, GetParentCallback));
        }
Esempio n. 2
0
        public static IEnumerable <OutlineItem> GetChildren(this OutlineItem item)
        {
            if (item?.Children == null)
            {
                return(LinqHelper.Empty <OutlineItem>());
            }

            return(item.Children);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the leaves of the outline item.
        /// </summary>
        /// <param name="item">The outline item where to start the search.</param>
        /// <returns>The leaves of the outline item.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="item"/> is <see langword="null"/>.
        /// </exception>
        public static IEnumerable <OutlineItem> GetLeaves(this OutlineItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            return(TreeHelper.GetLeaves(item, GetChildren));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the subtree (the given outline item and all of its descendants) using a depth-first or a
        /// breadth-first search.
        /// </summary>
        /// <param name="item">The outline item.</param>
        /// <param name="depthFirst">
        /// If set to <see langword="true"/> then a depth-first search for descendants will be made;
        /// otherwise a breadth-first search will be made.
        /// </param>
        /// <returns>The subtree (the given outline item and all of its descendants).</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="item"/> is <see langword="null"/>.
        /// </exception>
        public static IEnumerable <OutlineItem> GetSubtree(this OutlineItem item, bool depthFirst)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            return(TreeHelper.GetSubtree(item, GetChildren, depthFirst));
        }
Esempio n. 5
0
        /// <overloads>
        /// <summary>
        /// Gets the subtree (the given outline item and all of its descendants).
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Gets the subtree (the given outline item and all of its descendants) using a depth-first
        /// search.
        /// </summary>
        /// <param name="item">The outline item.</param>
        /// <returns>
        /// The subtree (the given outline item and all of its descendants) in depth-first order.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="item"/> is <see langword="null"/>.
        /// </exception>
        public static IEnumerable <OutlineItem> GetSubtree(this OutlineItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            return(TreeHelper.GetSubtree(item, GetChildrenCallback, true));
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the root item.
        /// </summary>
        /// <param name="item">The outline item.</param>
        /// <returns>The root item.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="item"/> is <see langword="null"/>.
        /// </exception>
        public static OutlineItem GetRoot(this OutlineItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            while (item.Parent != null)
            {
                item = item.Parent;
            }

            return(item);
        }