Metalama//API Documentation/Aspect API/Metalama.​Framework.​Code.​Collections/Enumerable­Extensions/Select­Many­Recursive
Open sandboxFocus

Method SelectManyRecursive

SelectManyRecursive<T>(IEnumerable<T>, Func<T, IEnumerable<T>>, Boolean)

Selects the closure of a graph. This is typically used to select all descendants of a tree node. This method returns distinct nodes only.

Declaration
public static IReadOnlyCollection<T> SelectManyRecursive<T>(this IEnumerable<T> collection, Func<T, IEnumerable<T>> getItems, bool deduplicate = false)
where T : class, ICompilationElement
Parameters
Type Name Description
IEnumerable<T> collection

The initial collection of items.

Func<T, IEnumerable<T>> getItems

A function that returns the set of all nodes connected to a given node.

Boolean deduplicate

true if duplicates should be removed from the result. When false, duplicates throw in Debug build, and are not checked (causing infinite loops) in Release build.

Returns
Type Description
IReadOnlyCollection<T>
Type Parameters
Name Description
T