Class Hierarchy<T>
- Namespace
- Cuemon.Extensions.Runtime
- Assembly
- Cuemon.Extensions.Core.dll
Represents a way to expose a node of a hierarchical structure, including the node object of type T
.
public sealed class Hierarchy<T> : Wrapper<T>, IHierarchy<T>, IWrapper<T>, IData
Type Parameters
T
The type of the object represented in the hierarchical structure.
- Inheritance
-
Wrapper<T>Hierarchy<T>
- Implements
-
IHierarchy<T>IWrapper<T>
- Inherited Members
- Extension Methods
Constructors
Hierarchy()
Initializes a new instance of the Hierarchy<T> class.
public Hierarchy()
Properties
Depth
Gets the current depth of the node in the hierarchical structure.
public int Depth { get; }
Property Value
- Int32
The current depth of the in the hierarchical structure.
HasChildren
Gets a value indicating whether this instance has any children.
public bool HasChildren { get; }
Property Value
- Boolean
true
if this instance has any children; otherwise,false
.
HasParent
Gets a value indicating whether this instance has a parent.
public bool HasParent { get; }
Property Value
- Boolean
true
if this instance has a parent; otherwise,false
.
Index
Gets the zero-based index of the current node that this hierarchical structure represents.
public int Index { get; }
Property Value
- Int32
The zero-based index of the current node that this hierarchical structure represents.
Item[Int32]
Gets the node at the specified index.
public IHierarchy<T> this[int index] { get; }
Parameters
index
Int32
Property Value
- IHierarchy<T>
The node at the specified index.
Methods
Add(T)
Adds the specified instance to a node in the hierarchical structure representation.
public IHierarchy<T> Add(T instance)
Parameters
instance
TThe instance to a node in the hierarchical structure represents.
Returns
- IHierarchy<T>
A reference to the newly added hierarchical node.
Add(T, MemberInfo)
Adds the specified instance to a node in the hierarchical structure representation.
public IHierarchy<T> Add(T instance, MemberInfo member)
Parameters
instance
TThe instance to a node in the hierarchical structure represents.
member
MemberInfoThe member from where
instance
was referenced.
Returns
- IHierarchy<T>
A reference to the newly added hierarchical node.
Add(T, Type)
Adds the specified instance to a node in the hierarchical structure representation.
public IHierarchy<T> Add(T instance, Type instanceType)
Parameters
instance
TThe instance to a node in the hierarchical structure represents.
instanceType
TypeThe type of
instance
.
Returns
- IHierarchy<T>
A reference to the newly added hierarchical node.
Exceptions
- ArgumentNullException
instanceType
is null.
Add(T, Type, MemberInfo)
Adds the specified instance to a node in the hierarchical structure representation.
public IHierarchy<T> Add(T instance, Type instanceType, MemberInfo member)
Parameters
instance
TThe instance to a node in the hierarchical structure represents.
instanceType
TypeThe type of
instance
.member
MemberInfoThe member from where
instance
was referenced.
Returns
- IHierarchy<T>
A reference to the newly added hierarchical node.
Exceptions
- ArgumentNullException
instanceType
is null.
GetChildren()
Gets an IEnumerable<T> sequence that represents all the child nodes of the current hierarchical node.
public IEnumerable<IHierarchy<T>> GetChildren()
Returns
- IEnumerable<IHierarchy<T>>
An IEnumerable<T> sequence that represents all the child nodes of the current hierarchical node.
GetParent()
Gets the parent node of the current node in the hierarchical structure.
public IHierarchy<T> GetParent()
Returns
- IHierarchy<T>
The parent node of the current node in the hierarchical structure.
GetPath()
Gets the hierarchical path of the node in the hierarchical structure.
public string GetPath()
Returns
GetPath(Func<IHierarchy<T>, String>)
Gets the hierarchical path of the node in the hierarchical structure.
public string GetPath(Func<IHierarchy<T>, string> pathResolver)
Parameters
pathResolver
Func<IHierarchy<T>, String>The function delegate path resolver.
Returns
Replace(T)
Allows for the instance on the current node to be replaced with a new instance
.
public void Replace(T instance)
Parameters
instance
TThe new instance to replace the original with.
Replace(T, Type)
Allows for the instance on the current node to be replaced with a new instance
.
public void Replace(T instance, Type instanceType)
Parameters
instance
TThe new instance to replace the original with.
instanceType
TypeThe type of the new instance.