Skip to content
ConsoleMonster
Class

TreeHierarchy

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
static

Builds tree nodes from hierarchical objects (groups and members, folders and files, an org chart): a function gives each item's node and another its children. Depth, width and size limits keep a large or cyclic hierarchy readable and bounded; what is left out is marked in the tree instead of being dropped silently.

Inheritance

  • object
  • TreeHierarchy

Methods

public static int Add<T>(TreeNode parent, IEnumerable<T?> items, Func<T?, TreeNode> node, Func<T?, IEnumerable<T?>?> children, TreeHierarchyOptions? options = null) #

Adds the items and their descendants under a node.

Type Parameters

T
The item type.

Parameters

parent ConsoleMonster.Widgets.TreeNode required
The node to add to (for example Tree.Root).
items System.Collections.Generic.IEnumerable<T?> required
The top-level items.
node System.Func<T?, ConsoleMonster.Widgets.TreeNode> required
Creates the node for an item (its label, status and note); children are added by the walk.
children System.Func<T?, System.Collections.Generic.IEnumerable<T?>?> required
The children of an item, or null when it has none.
options ConsoleMonster.Widgets.TreeHierarchyOptions? = null optional
The limits, or null for the defaults.

Returns

int The number of item nodes added (limit notes not counted).