Class LinqExtensions
Inheritance
LinqExtensions
Assembly: LemonEdge.Utils.dll
Syntax
public static class LinqExtensions
Methods
AsArray<T>(T)
Converts a single item of T into a one element array of T.
Declaration
public static T[] AsArray<T>(this T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
Type Parameters
Flatten<T>(IEnumerable<T>, Func<T, IEnumerable<T>, IEnumerable<T>>)
This method extends the LINQ methods to flatten a collection of
items that have a property of children of the same type.
Declaration
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>, IEnumerable<T>> childPropertySelector)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
source |
Source collection.
|
Func<T, IEnumerable<T>, IEnumerable<T>> |
childPropertySelector |
Child property selector delegate of each item.
IEnumerable'T' childPropertySelector
(T itemBeingFlattened, IEnumerable'T' objectsBeingFlattened)
|
Returns
Type |
Description |
IEnumerable<T> |
Returns a one level list of elements of type T.
|
Type Parameters
Name |
Description |
T |
Item type.
|
Flatten<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
This method extends the LINQ methods to flatten a collection of
items that have a property of children of the same type.
Declaration
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childPropertySelector)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
source |
Source collection.
|
Func<T, IEnumerable<T>> |
childPropertySelector |
Child property selector delegate of each item.
IEnumerable'T' childPropertySelector(T itemBeingFlattened)
|
Returns
Type |
Description |
IEnumerable<T> |
Returns a one level list of elements of type T.
|
Type Parameters
Name |
Description |
T |
Item type.
|
Max<T, Y>(IEnumerable<T>, Func<T, Y>, Y)
Declaration
public static Y Max<T, Y>(this IEnumerable<T> items, Func<T, Y> predicate, Y def) where Y : struct, IComparable<Y>
Parameters
Returns
Type Parameters
Min<T, Y>(IEnumerable<T>, Func<T, Y>, Y)
Declaration
public static Y Min<T, Y>(this IEnumerable<T> items, Func<T, Y> predicate, Y def) where Y : struct, IComparable<Y>
Parameters
Returns
Type Parameters
Sum<T>(IEnumerable<T>, Func<T, decimal>, decimal)
Declaration
public static decimal Sum<T>(this IEnumerable<T> items, Func<T, decimal> predicate, decimal def)
Parameters
Returns
Type Parameters
ToArrayOfOne<T>(T)
Turns this T item into:
new T[]{item};
Declaration
public static T[] ToArrayOfOne<T>(this T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
Type Parameters
ToListOfOne<T>(T)
Turns this T item into:
new List{T}{item};
Declaration
public static IList<T> ToListOfOne<T>(this T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
Type |
Description |
IList<T> |
|
Type Parameters
WithIndex<T>(IEnumerable<T>)
Generates an enumeration with the corresponding index value.
Declaration
public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> source)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
source |
The source enumeration.
|
Returns
Type Parameters
Name |
Description |
T |
The generic type.
|