Show / Hide Table of Contents

Class HierarchyDecoratorExtensions

Extension methods for the IHierarchy<T> interface tailored to adhere the decorator pattern.

Inheritance
Object
HierarchyDecoratorExtensions
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class HierarchyDecoratorExtensions

Methods

| Improve this Doc View Source

AncestorsAndSelf<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 decorator.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 match, or a default value if no node is found.

Type Parameters
Name Description
T

The type of the instance that this node represents.

| Improve this Doc View Source

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 match, or a default value if no node is found.

Type Parameters
Name Description
T

The type of the instance that this node represents.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 match, or a default value if no node is found.

Type Parameters
Name Description
T

The type of the instance that this node represents.

| Improve this Doc View Source

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 match, or a default value if no node instance is found.

Type Parameters
Name Description
T

The type of the instance that this node represents.

| Improve this Doc View Source

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 decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

| Improve this Doc View Source

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 index in the hierarchical structure.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

ArgumentOutOfRangeException

index is less than zero - or - index exceeded the count of nodes in the hierarchical structure.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance that this node represents.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance that these nodes represents.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

| Improve this Doc View Source

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 decorator.

Type Parameters
Name Description
T

The type of the instance represented by the specified decorator in the hierarchical structure.

Exceptions
Type Condition
ArgumentNullException

decorator is null.

ArgumentOutOfRangeException

depth is less than zero.

| Improve this Doc View Source

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 valueType from the enclosed IHierarchy{DataPair} of the decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 decorator.

| Improve this Doc View Source

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 decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 valueTypes from the enclosed IHierarchy{DataPair} of the decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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 decorator.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

See Also

IDecorator<T>
Decorator<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright 2008-2022 Geekle. All rights reserved. Code with passion and love; deploy with confidence. 👨‍💻️🔥❤️🚀😎
Generated by DocFX