Class HierarchyDecoratorExtensions
Extension methods for the IHierarchy<T> interface tailored to adhere the decorator pattern.
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class HierarchyDecoratorExtensions
Methods
| Improve this Doc View SourceAncestorsAndSelf<T>(IDecorator<IHierarchy<T>>)
Gets all ancestors (parent, grandparent, etc.) and self of the specified decorator
in the hierarchical structure.
Declaration
public static IEnumerable<IHierarchy<T>> AncestorsAndSelf<T>(this IDecorator<IHierarchy<T>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence equal to ancestors and self of the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
DescendantsAndSelf<T>(IDecorator<IHierarchy<T>>)
Gets all descendants (children, grandchildren, etc.) anf self of the current decorator
in the hierarchical structure.
Declaration
public static IEnumerable<IHierarchy<T>> DescendantsAndSelf<T>(this IDecorator<IHierarchy<T>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence equal to the descendants and self of the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Find<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Retrieves all nodes that match the conditions defined by the function delegate match
.
Declaration
public static IEnumerable<IHierarchy<T>> Find<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence containing all nodes that match the conditions defined by the specified predicate, if found. |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FindFirst<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Returns the first node that match the conditions defined by the function delegate match
, or a default value if no node is found.
Declaration
public static IHierarchy<T> FindFirst<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
IHierarchy<T> | An IHierarchy<T> node that match the conditions defined by the function delegate |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FindFirstInstance<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Returns the first node instance that match the conditions defined by the function delegate match
, or a default value if no node is found.
Declaration
public static T FindFirstInstance<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
T | An Instance that match the conditions defined by the function delegate |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FindInstance<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Retrieves all node instances that match the conditions defined by the function delegate match
.
Declaration
public static IEnumerable<T> FindInstance<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
IEnumerable<T> | An IEnumerable<T> sequence containing all node instances that match the conditions defined by the specified predicate, if found. |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FindSingle<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Returns the only node that match the conditions defined by the function delegate match
, or a default value if no node is found; this method throws an exception if more than one node is found.
Declaration
public static IHierarchy<T> FindSingle<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
IHierarchy<T> | An IHierarchy<T> node that match the conditions defined by the function delegate |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FindSingleInstance<T>(IDecorator<IHierarchy<T>>, Func<IHierarchy<T>, Boolean>)
Returns the only node that match the conditions defined by the function delegate match
, or a default value if no node instance is found; this method throws an exception if more than one node is found.
Declaration
public static T FindSingleInstance<T>(this IDecorator<IHierarchy<T>> decorator, Func<IHierarchy<T>, bool> match)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Func<IHierarchy<T>, Boolean> | match | The function delegate that defines the conditions of the nodes to search for. |
Returns
Type | Description |
---|---|
T | An Instance node that match the conditions defined by the function delegate |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
FlattenAll<T>(IDecorator<IHierarchy<T>>)
Flattens the entirety of a hierarchical structure representation into an IEnumerable<T> sequence of nodes.
Declaration
public static IEnumerable<IHierarchy<T>> FlattenAll<T>(this IDecorator<IHierarchy<T>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence of IHierarchy<T> all nodes represented by the hierarchical structure. |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
NodeAt<T>(IDecorator<IHierarchy<T>>, Int32)
Returns the node at the specified index of a hierarchical structure.
Declaration
public static IHierarchy<T> NodeAt<T>(this IDecorator<IHierarchy<T>> decorator, int index)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Int32 | index | The zero-based index at which a node should be retrieved in the hierarchical structure. |
Returns
Type | Description |
---|---|
IHierarchy<T> | The node at the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
Replace<T>(IDecorator<IHierarchy<T>>, Action<IHierarchy<T>, T>)
Replace the instance of the decorator
with a replacer
delegate.
Declaration
public static void Replace<T>(this IDecorator<IHierarchy<T>> decorator, Action<IHierarchy<T>, T> replacer)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Action<IHierarchy<T>, T> | replacer | The delegate that will replace the wrapped instance of the |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that this node represents. |
ReplaceAll<T>(IDecorator<IEnumerable<IHierarchy<T>>>, Action<IHierarchy<T>, T>)
Replace all instances of the decorator
with a replacer
delegate.
Declaration
public static void ReplaceAll<T>(this IDecorator<IEnumerable<IHierarchy<T>>> decorator, Action<IHierarchy<T>, T> replacer)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IEnumerable<IHierarchy<T>>> | decorator | The IDecorator{IEnumerable{IHierarchy{T}}} to extend. |
Action<IHierarchy<T>, T> | replacer | The delegate that will replace all wrapped instances of the |
Type Parameters
Name | Description |
---|---|
T | The type of the instance that these nodes represents. |
Root<T>(IDecorator<IHierarchy<T>>)
Returns the root node of the specified decorator
in the hierarchical structure.
Declaration
public static IHierarchy<T> Root<T>(this IDecorator<IHierarchy<T>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Returns
Type | Description |
---|---|
IHierarchy<T> | An IHierarchy<T> node that represents the root of the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SiblingsAndSelf<T>(IDecorator<IHierarchy<T>>)
Gets all siblings and self after the current decorator
in the hierarchical structure.
Declaration
public static IEnumerable<IHierarchy<T>> SiblingsAndSelf<T>(this IDecorator<IHierarchy<T>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence equal to the siblings and self of the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SiblingsAndSelfAt<T>(IDecorator<IHierarchy<T>>, Int32)
Gets all siblings and self after the current decorator
in the hierarchical structure.
Declaration
public static IEnumerable<IHierarchy<T>> SiblingsAndSelfAt<T>(this IDecorator<IHierarchy<T>> decorator, int depth)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<T>> | decorator | The IDecorator{IHierarchy{T}} to extend. |
Int32 | depth | The depth in the hierarchical structure from where to locate the siblings and self nodes. |
Returns
Type | Description |
---|---|
IEnumerable<IHierarchy<T>> | An IEnumerable<T> sequence equal to the siblings and self of the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the instance represented by the specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
UseCollection(IDecorator<IHierarchy<DataPair>>, Type)
A formatter implementation that resolves a ICollection.
Declaration
public static ICollection UseCollection(this IDecorator<IHierarchy<DataPair>> decorator, Type valueType)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Type | valueType | The type of the objects in the collection. |
Returns
Type | Description |
---|---|
ICollection | A ICollection of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseConvertibleFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a IConvertible.
Declaration
public static IConvertible UseConvertibleFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
IConvertible | A IConvertible from the enclosed IHierarchy{DataPair} of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseDateTimeFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a DateTime.
Declaration
public static DateTime UseDateTimeFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
DateTime | A DateTime from the enclosed IHierarchy{DataPair} of the |
UseDecimalFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a Decimal.
Declaration
public static decimal UseDecimalFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
Decimal | A Decimal from the enclosed IHierarchy{DataPair} of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseDictionary(IDecorator<IHierarchy<DataPair>>, Type[])
A formatter implementation that resolves a IDictionary.
Declaration
public static IDictionary UseDictionary(this IDecorator<IHierarchy<DataPair>> decorator, Type[] valueTypes)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Type[] | valueTypes | The value types that forms a KeyValuePair<TKey,TValue>. |
Returns
Type | Description |
---|---|
IDictionary | A IDictionary with KeyValuePair<TKey,TValue> of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseGuidFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a Guid.
Declaration
public static Guid UseGuidFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
Guid | A Guid from the enclosed IHierarchy{DataPair} of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseStringFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a String.
Declaration
public static string UseStringFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
String | A String from the enclosed IHierarchy{DataPair} of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UseUriFormatter(IDecorator<IHierarchy<DataPair>>)
A formatter implementation that resolves a Uri.
Declaration
public static Uri UseUriFormatter(this IDecorator<IHierarchy<DataPair>> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<IHierarchy<DataPair>> | decorator | The IDecorator{IHierarchy{DataPair}} to extend. |
Returns
Type | Description |
---|---|
Uri | A Uri from the enclosed IHierarchy{DataPair} of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|