/// <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)); }
public static IEnumerable <OutlineItem> GetChildren(this OutlineItem item) { if (item?.Children == null) { return(LinqHelper.Empty <OutlineItem>()); } return(item.Children); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }