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>, bool>)
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
hierarchyIHierarchy<T>The IHierarchy<T> implementation to perform the operation upon.
matchFunc<IHierarchy<T>, bool>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
TThe 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
sourceobjectThe source whose properties will be traversed while building the hierarchical structure.
setupAction<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
sourceis 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
sourceTSourceThe source to travel until the
traversalpath is obstructed by an empty sequence.traversalFunc<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
TSourceThe type of the
source.
Exceptions
- ArgumentNullException
source-or-traversalis 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
sourceTSourceThe source to travel until the
traversalpath is obstructed by a null value.traversalFunc<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
TSourceThe type of the
source.
Exceptions
- ArgumentNullException
source-or-traversalis null.