Show / Hide Table of Contents

    Class HierarchyExtensions

    Extension methods for a hierarchical structure based on IHierarchy<T>.

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

    Methods

    | Improve this Doc

    AncestorsAndSelf<T>(IHierarchy<T>)

    Gets all ancestors (parent, grandparent, etc.) and self of the specified node in the hierarchical structure.

    Declaration
    public static IEnumerable<IHierarchy<T>> AncestorsAndSelf<T>(this IHierarchy<T> node)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node that the hierarchical structure represents.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.IEnumerable<T> sequence equal to ancestors and self of the specified node.

    Type Parameters
    Name Description
    T

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    | Improve this Doc

    DescendantsAndSelf<T>(IHierarchy<T>)

    Gets all descendants (children, grandchildren, etc.) anf self of the current node in the hierarchical structure.

    Declaration
    public static IEnumerable<IHierarchy<T>> DescendantsAndSelf<T>(this IHierarchy<T> node)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node that the hierarchical structure represents.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.IEnumerable<T> sequence equal to the descendants and self of the specified node.

    Type Parameters
    Name Description
    T

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    | Improve this Doc

    Find<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.Boolean> match

    The function delegate that defines the conditions of the nodes to search for.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.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

    FindFirst<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.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

    FindFirstInstance<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.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

    FindInstance<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.Boolean> match

    The function delegate that defines the conditions of the nodes to search for.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T>

    An System.Collections.Generic.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

    FindSingle<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.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

    FindSingleInstance<T>(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 IHierarchy<T> node, Func<IHierarchy<T>, bool> match)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to search.

    System.Func<IHierarchy<T>, System.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

    FlattenAll<T>(IHierarchy<T>)

    Flattens the entirety of a hierarchical structure representation into an System.Collections.Generic.IEnumerable<T> sequence of nodes.

    Declaration
    public static IEnumerable<IHierarchy<T>> FlattenAll<T>(this IHierarchy<T> node)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node from which the flattening will begin.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.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 node in the hierarchical structure.

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    | Improve this Doc

    NodeAt<T>(IHierarchy<T>, Int32)

    Returns the node at the specified index of a hierarchical structure.

    Declaration
    public static IHierarchy<T> NodeAt<T>(this IHierarchy<T> node, int index)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node from which the flattening will begin.

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    System.ArgumentOutOfRangeException

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

    | Improve this Doc

    Replace<T>(IHierarchy<T>, Action<IHierarchy<T>, T>)

    Replace the instance of the node with a replacer delegate.

    Declaration
    public static void Replace<T>(this IHierarchy<T> node, Action<IHierarchy<T>, T> replacer)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node to replace with a new instance.

    System.Action<IHierarchy<T>, T> replacer

    The delegate that will replace the wrapped instance of the node.

    Type Parameters
    Name Description
    T

    The type of the instance that this node represents.

    | Improve this Doc

    ReplaceAll<T>(IEnumerable<IHierarchy<T>>, Action<IHierarchy<T>, T>)

    Replace all instances of the nodes with a replacer delegate.

    Declaration
    public static void ReplaceAll<T>(this IEnumerable<IHierarchy<T>> nodes, Action<IHierarchy<T>, T> replacer)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>> nodes

    The sequence of nodes to replace with a new instance.

    System.Action<IHierarchy<T>, T> replacer

    The delegate that will replace all wrapped instances of the nodes.

    Type Parameters
    Name Description
    T

    The type of the instance that these nodes represents.

    | Improve this Doc

    Root<T>(IHierarchy<T>)

    Returns the root node of the specified node in the hierarchical structure.

    Declaration
    public static IHierarchy<T> Root<T>(this IHierarchy<T> node)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node that the hierarchical structure represents.

    Returns
    Type Description
    IHierarchy<T>

    An IHierarchy<T> node that represents the root of the specified node.

    Type Parameters
    Name Description
    T

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    | Improve this Doc

    SiblingsAndSelf<T>(IHierarchy<T>)

    Gets all siblings and self after the current node in the hierarchical structure.

    Declaration
    public static IEnumerable<IHierarchy<T>> SiblingsAndSelf<T>(this IHierarchy<T> node)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node that the hierarchical structure represents.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.IEnumerable<T> sequence equal to the siblings and self of the specified node.

    Type Parameters
    Name Description
    T

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    | Improve this Doc

    SiblingsAndSelfAt<T>(IHierarchy<T>, Int32)

    Gets all siblings and self after the current node in the hierarchical structure.

    Declaration
    public static IEnumerable<IHierarchy<T>> SiblingsAndSelfAt<T>(this IHierarchy<T> node, int depth)
    Parameters
    Type Name Description
    IHierarchy<T> node

    The node that the hierarchical structure represents.

    System.Int32 depth

    The depth in the hierarchical structure from where to locate the siblings and self nodes.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IHierarchy<T>>

    An System.Collections.Generic.IEnumerable<T> sequence equal to the siblings and self of the specified node.

    Type Parameters
    Name Description
    T

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

    Exceptions
    Type Condition
    System.ArgumentNullException

    node is null.

    System.ArgumentOutOfRangeException

    depth is less than zero.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX