/// <summary> Initializes a new instance of the <see cref="HierarchyListNode{T}" /> class. </summary> /// <param name="value"> The value. </param> /// <param name="parent"> The parent. </param> /// <param name="depth"> The depth of a node. </param> internal HierarchyListNode(T value, HierarchyListNode <T> parent, int depth) { Id = Guid.NewGuid(); Value = value; Parent = parent; Depth = depth; }
/// <summary> Adds a children. </summary> /// <param name="item"> The children. </param> public HierarchyListNode <T> AddChildren(T item) { var hierarchyListNode = new HierarchyListNode <T>(item, this, Depth + 1); _children.Add(hierarchyListNode); return(hierarchyListNode); }
/// <summary> Initializes a new instance of the <see cref="HierarchyList{T}" /> class. </summary> /// <param name="rootItem"> The root item. </param> public HierarchyList(T rootItem) { Root = new HierarchyListNode <T>(rootItem, null, 0); }
public static IEnumerable <HierarchyListNode <T> > GetDescendants <T>([NotNull] this HierarchyListNode <T> node) { return(GetChildrenRecursive(node.Children));