Class NavigableNode<T>
- Namespace
- Yarhl.FileSystem
- Assembly
- Yarhl.dll
Node with navigation features inside a FileSystem.
public abstract class NavigableNode<T> : IDisposable where T : NavigableNode<T>
Type Parameters
T
The implementation of NavigableNodes.
- Inheritance
-
NavigableNode<T>
- Implements
- Derived
- Inherited Members
Constructors
NavigableNode(string)
Initializes a new instance of the NavigableNode<T> class.
protected NavigableNode(string name)
Parameters
name
stringNode name.
Properties
Children
Gets a read-only list of children nodes.
public NavigableNodeCollection<T> Children { get; }
Property Value
Disposed
Gets a value indicating whether this node is disposed.
public bool Disposed { get; }
Property Value
Name
Gets or sets the node name.
public string Name { get; set; }
Property Value
Parent
Gets the parent node.
public T? Parent { get; }
Property Value
- T
The reference to the parent node or null if it doesn't have any parent.
Path
Gets the path.
public string Path { get; }
Property Value
Remarks
It includes the names of all the parent nodes and this node.
As nodes may change their name, the path from children may change at any time. Do not store it as keys.
Tags
Gets the dictionary of tags.
public IDictionary<string, dynamic> Tags { get; }
Property Value
- IDictionary<string, dynamic>
Methods
Add(IEnumerable<T>)
Add a list of nodes.
public void Add(IEnumerable<T> nodes)
Parameters
nodes
IEnumerable<T>List of nodes to add.
Add(T)
Add a node.
public void Add(T node)
Parameters
node
TNode to add.
Remarks
Updates the parent of the child node to match this instance. If the node already contains a child with the same name it will be replaced. Otherwise the node is added.
Dispose()
Releases all resource used by the Node object.
public void Dispose()
Dispose(bool)
Releases all resource used by the NavigableNode<T> object.
protected virtual void Dispose(bool freeManagedResourcesAlso)
Parameters
Remove(string)
Remove a node with the specified name.
public bool Remove(string name)
Parameters
name
stringThe name of the node to remove.
Returns
- bool
Whether the node was found and removed successfully.
Remarks
This method does dispose the removed node. If you don't want to dispose it, search the node and call the overload with the node argument.
Remove(T)
Remove a node.
public bool Remove(T node)
Parameters
node
TNode reference to remove.
Returns
- bool
Whether the node was found and removed successfully.
Remarks
This method does NOT dispose the removed node.
RemoveChildren(bool)
Removes and dispose all the children from the node.
public void RemoveChildren(bool dispose = true)
Parameters
SortChildren(bool)
Sorts the children nodes using the default comparer.
public void SortChildren(bool recursive = true)
Parameters
SortChildren(IComparer<T>, bool)
Sorts the children nodes using the specified comparer.
public void SortChildren(IComparer<T> comparer, bool recursive = true)
Parameters
comparer
IComparer<T>The IComparer<T> implementation to use when comparing elements.
recursive
boolIf set to true sorts the children nodes recursively.
SortChildren(Comparison<T>, bool)
Sorts the children nodes using the specified Comparison<T>.
public void SortChildren(Comparison<T> comparison, bool recursive = true)
Parameters
comparison
Comparison<T>The Comparison<T> to use when comparing elements.
recursive
boolIf set to true sorts the children nodes recursively.