Class LinqExtensions
Provides a set of static methods extending the IEnumerable<T> class.
public static class LinqExtensions
- Inheritance
-
LinqExtensions
- Inherited Members
Methods
Flatten<TSource>(IEnumerable<TSource>, Func<TSource, IEnumerable<TSource>>)
Take a collection of an object of type TSource and use the getChildrenFunction to travel the structure of the collection. In return, we have a flatten collection of each nodes.
public static IEnumerable<TSource> Flatten<TSource>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TSource>> getChildrenFunction)
Parameters
sourceIEnumerable<TSource>An IEnumerable<T> to flatten recursively.
getChildrenFunctionFunc<TSource, IEnumerable<TSource>>Return the property to use to travel through the node collection.
Returns
- IEnumerable<TSource>
Type Parameters
TSourceThe type of the elements of
source.
Where<TSource>(IEnumerable<TSource>, Func<TSource, bool>, Func<TSource, IEnumerable<TSource>>)
Filters recursively a sequence of values based on a predicate.
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, IEnumerable<TSource>> selector)
Parameters
sourceIEnumerable<TSource>An IEnumerable<T> to filter recursively.
predicateFunc<TSource, bool>A function to test each element for a condition.
selectorFunc<TSource, IEnumerable<TSource>>A recursive function to apply to each element.
Returns
- IEnumerable<TSource>
An IEnumerable<T> that contains elements from the input sequence that satisfy the condition.
Type Parameters
TSourceThe type of the elements of
source.