Class Hierarchy
- Namespace
- Cuemon.Extensions.Runtime
- Assembly
- Cuemon.Extensions.Core.dll
Provides a set of static methods for hierarchy related operations.
public static class Hierarchy
- Inheritance
-
Hierarchy
Methods
Find<T>(IHierarchy<T>, Func<IHierarchy<T>, Boolean>)
Retrieves all nodes that match the conditions defined by the function delegate match
.
public static IEnumerable<IHierarchy<T>> Find<T>(IHierarchy<T> hierarchy, Func<IHierarchy<T>, bool> match)
Parameters
hierarchy
IHierarchy<T>The IHierarchy<T> implementation to perform the operation upon.
match
Func<IHierarchy<T>, Boolean>The function delegate that defines the conditions of the nodes to search for.
Returns
- IEnumerable<IHierarchy<T>>
An IEnumerable<T> sequence containing all nodes that match the conditions defined by the specified predicate, if found.
Type Parameters
T
The type of the instance that this node represents.
GetObjectHierarchy(Object, Action<HierarchyOptions>)
Gets the tree structure of the specified source
wrapped in an IHierarchy<T> node representing a hierarchical structure.
public static IHierarchy<object> GetObjectHierarchy(object source, Action<HierarchyOptions> setup = null)
Parameters
source
ObjectThe source whose properties will be traversed while building the hierarchical structure.
setup
Action<HierarchyOptions>The HierarchyOptions which need to be configured.
Returns
- IHierarchy<Object>
An IHierarchy<T> node representing the entirety of a hierarchical structure from the specified
source
.
Exceptions
- ArgumentNullException
source
is null.
TraverseWhileNotEmpty<TSource>(TSource, Func<TSource, IEnumerable<TSource>>)
Invokes the specified traversal
path of source
until obstructed by an empty sequence.
public static IEnumerable<TSource> TraverseWhileNotEmpty<TSource>(TSource source, Func<TSource, IEnumerable<TSource>> traversal)
where TSource : class
Parameters
source
TSourceThe source to travel until the
traversal
path is obstructed by an empty sequence.traversal
Func<TSource, IEnumerable<TSource>>The function delegate that is invoked until the traveled path is obstructed by an empty sequence.
Returns
- IEnumerable<TSource>
An IEnumerable<T> sequence equal to the traveled path of
source
.
Type Parameters
TSource
The type of the
source
.
Exceptions
- ArgumentNullException
source
-or-traversal
is null.
TraverseWhileNotNull<TSource>(TSource, Func<TSource, TSource>)
Invokes the specified traversal
path of source
until obstructed by a null value.
public static IEnumerable<TSource> TraverseWhileNotNull<TSource>(TSource source, Func<TSource, TSource> traversal)
where TSource : class
Parameters
source
TSourceThe source to travel until the
traversal
path is obstructed by a null value.traversal
Func<TSource, TSource>The function delegate that is invoked until the traveled path is obstructed by a null value.
Returns
- IEnumerable<TSource>
An IEnumerable<T> sequence equal to the traveled path of
source
.
Type Parameters
TSource
The type of the
source
.
Exceptions
- ArgumentNullException
source
-or-traversal
is null.