Skip to content

Node<TNode> Class ​

Definition ​

Abstract base class for nodes in a tree.

c#
public abstract class Node<TNode>
   where TNode : Node<TNode>

View source

Type Parameters ​

NameDescription
TNodeSelf generic node parameter.

Constructors ​

NameDescription
Node()Initialises a new instance of the Node<TNode> class.
Node(IEnumerable<TNode>)Initialises a new instance of the Node<TNode> class with the specified children.

Properties ​

NameDescription
AncestorsLazily enumerates over the ancestors of this node, that is, the Parent, grandparent, great-grandparent and all remaining ancestors up to the root node.
ChildrenThe children of this node.
DescendantsEnumerates all descendants of this node in depth first pre-order.
ErrorsThe Messages with Level Error associated with this node.
HasChildrenReturns true if this node has any Children, false otherwise.
HasErrorsReturns true if this node has any Messages with Level Error, false otherwise.
HasInfosReturns true if this node has any Messages with Level Info, false otherwise.
HasMessagesReturns true if this node has any Messages, false otherwise.
HasNextSiblingReturns true if this node has a NextSibling, false otherwise.
HasParentReturns true if this node has a Parent, false otherwise. Nodes will not have parents if they are the root node, or they have just been constructed and not yet added to a parent.
HasPreviousSiblingReturns true if this node has a PreviousSibling, false otherwise.
HasWarningsReturns true if this node has any Messages with Level Warning, false otherwise.
IndexInParentThe index of this node in the Parent or -1 if this node has no Parent.
InfosThe Messages with Level Info associated with this node.
IsFirstChildtrue if this node is the first child in Parent, false if not or if the node has no Parent.
IsLastChildtrue if this node is the last child in Parent, false if not or if the node has no Parent.
MessagesThe Messages associated with this node.
NextSiblingThe next sibling, that is, the child from the same Parent at the next positional index. Returns null if this node is the last child.
NextSiblingsLazily enumerates over the next siblings, that is, the children from the same Parent at subsequent positional indices in ascending index order.
ParentThe parent of this node.
PreviousSiblingThe previous sibling, that is, the child from the same Parent at the previous positional index. Returns null if this node is the first child.
PreviousSiblingsLazily enumerates over the previous siblings, that is, the children from the same Parent at precedent positional indices in descending index order.
RootThe root node, that is, the highest parent above this node. Returns this node if it is the root, that is, it has no parents.
SourcePositionThe position of the node in the source code.
ThisAndAncestorsLazily enumerates over this node and its Ancestors, that is, this node, the Parent, grandparent, great-grandparent and all remaining ancestors up to the root node.
ThisAndDescendantsEnumerates this node then all descendants of this node in depth first pre-order.
ThisAndDescendantsHaveErrorsReturns true if this node or any of its descendants have any Messages with Level Error, false otherwise.
ThisAndDescendantsHaveInfosReturns true if this node or any of its descendants have any Messages with Level Info, false otherwise.
ThisAndDescendantsHaveMessagesReturns true if this node or any of its descendants have any Messages, false otherwise.
ThisAndDescendantsHaveWarningsReturns true if this node or any of its descendants have any Messages with Level Warning, false otherwise.
ThisAndDescendantsWithErrorsLazily enumerates over this node and its descendants returning only those that have Messages with Level Error.
ThisAndDescendantsWithInfosLazily enumerates over this node and its descendants returning only those that have Messages with Level Info.
ThisAndDescendantsWithMessagesLazily enumerates over this node and its descendants returning only those that have Messages.
ThisAndDescendantsWithWarningsLazily enumerates over this node and its descendants returning only those that have Messages with Level Warning.
ThisAndNextSiblingsLazily enumerates over this node then the next siblings, that is, the children from the same Parent at subsequent positional indices in ascending index order.
ThisAndPreviousSiblingsLazily enumerates over this node then the previous siblings, that is, the children from the same Parent at precedent positional indices in descending index order.
WarningsThe Messages with Level Warning associated with this node.

Methods ​

NameDescription
AddError(String)Adds a Message with Level Error and the specified text to this node.
AddError(String, String)Adds a Message with Level Error and the specified text to this node.
AddInfo(String)Adds a Message with Level Info and the specified text to this node.
AddInfo(String, String)Adds a Message with Level Info and the specified text to this node.
AddMessage(Message)Adds a Message to this node.
AddMessage(MessageLevel, String)Adds a Message with the specified Level and Text to this node.
AddMessage(MessageLevel, String, String)Adds a Message with the specified Level, Code and Text to this node.
AddNextSibling(TNode)Adds the specified node as the NextSibling to this node. Existing next siblings will be moved on index to the right to accommodate.
AddPreviousSibling(TNode)Adds the specified node as the PreviousSibling to this node. This and any next siblings will be moved one index to the right to accommodate.
AddWarning(String)Adds a Message with Level Warning and the specified text to this node.
AddWarning(String, String)Adds a Message with Level Warning and the specified text to this node.
AncestorsOfType<TAncestor>()Lazily enumerates over this node and its Ancestors, returning only ancestors of the specified type.
MoveTo(TNode)Moves this node to a new parent.
RemoveFromParent()Removes this node from its Parent.
RemoveNextSibling()Removes the NextSibling from Parent if it exists.
RemovePreviousSibling()Removes the PreviousSibling from Parent if it exists.
ReplaceWith(Node<TNode>)Removes this node from it's parent and puts another node in its place.
ThisAnd(IEnumerable<TNode>)Lazily enumerates over this node and then the specified enumeration of nodes.
ThisAndAncestorsOfType<TAncestor>()Lazily enumerates over the Ancestors of this node, returning only ancestors of the specified type.
ToString()Returns a string that represents the current node. Defaults to the name of the type of the node.