PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.AsyncExtensionsForIEnumerables Class Reference

Useful extensions for IEnumerable<T> collections, with async in mind. More...

Static Public Member Functions

static async Task ForEachAsync< T > (this IEnumerable< T > collection, Func< T, Task > toRun)
 The missing ForEach method - async variant. Don't forget to await on it!
static async Task ForEachAsync< T > (this IEnumerable< T > collection, Func< T, int, Task > toRunWithIndex)
 The missing ForEach method - asynchronous variant which also provides the current item index -> DON'T forget to await!
static async Task< T[]> ToArrayAsync< T > (this Task< IEnumerable< T > > src)
 Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.
static async Task< T[]> ToArrayAsync< T > (this Task< T[]> src)
 Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.
static async Task< T[]> ToArrayAsync< T > (this Task< List< T > > src)
 Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.
static async Task< TAccumulator > AggregateAsync< TAccumulator, TItem > (this IEnumerable< TItem > items, TAccumulator seed, Func< TAccumulator, TItem, Task< TAccumulator > > reducer)
 Provides an awaitable Aggregate for collections.
static async Task< TOut[]> SelectAsync< TIn, TOut > (this IEnumerable< TIn > src, Func< TIn, Task< TOut > > transform)
 Provides an awaitable variant of Select()
static async Task< IEnumerable< T > > WhereAsync< T > (this IEnumerable< T > src, Func< T, Task< bool > > discriminator)
 Provides an awaitable .Where() where your discriminator function can be async. Will return an empty collection if operating on null.

Detailed Description

Useful extensions for IEnumerable<T> collections, with async in mind.

Member Function Documentation

◆ AggregateAsync< TAccumulator, TItem >()

async Task< TAccumulator > PeanutButter.Utils.AsyncExtensionsForIEnumerables.AggregateAsync< TAccumulator, TItem > ( this IEnumerable< TItem > items,
TAccumulator seed,
Func< TAccumulator, TItem, Task< TAccumulator > > reducer )
static

Provides an awaitable Aggregate for collections.

Template Parameters
TAccumulator
TItem
Parameters
itemsCollection to operate on
seedSeed accumulator object
reducerFunction to call on each item, reducing the overall result. It will be given the accumulator from the last round (or the seed if it is the first time it is called) and should return an accumulator which the next round can use.
Returns

◆ ForEachAsync< T >() [1/2]

async Task PeanutButter.Utils.AsyncExtensionsForIEnumerables.ForEachAsync< T > ( this IEnumerable< T > collection,
Func< T, int, Task > toRunWithIndex )
static

The missing ForEach method - asynchronous variant which also provides the current item index -> DON'T forget to await!

Parameters
collectionSubject collection to operate over
toRunWithIndexAction to run on each member of the collection
Template Parameters
TItem type of the collection

◆ ForEachAsync< T >() [2/2]

async Task PeanutButter.Utils.AsyncExtensionsForIEnumerables.ForEachAsync< T > ( this IEnumerable< T > collection,
Func< T, Task > toRun )
static

The missing ForEach method - async variant. Don't forget to await on it!

Parameters
collectionSubject collection to operate over
toRunAction to run on each member of the collection
Template Parameters
TItem type of the collection

◆ SelectAsync< TIn, TOut >()

async Task< TOut[]> PeanutButter.Utils.AsyncExtensionsForIEnumerables.SelectAsync< TIn, TOut > ( this IEnumerable< TIn > src,
Func< TIn, Task< TOut > > transform )
static

Provides an awaitable variant of Select()

Template Parameters
TIn
TOut
Parameters
srcSource collection to operate on
transform
Returns

◆ ToArrayAsync< T >() [1/3]

async Task< T[]> PeanutButter.Utils.AsyncExtensionsForIEnumerables.ToArrayAsync< T > ( this Task< IEnumerable< T > > src)
static

Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.

Template Parameters
T
Parameters
src
Returns

◆ ToArrayAsync< T >() [2/3]

async Task< T[]> PeanutButter.Utils.AsyncExtensionsForIEnumerables.ToArrayAsync< T > ( this Task< List< T > > src)
static

Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.

Template Parameters
T
Parameters
src
Returns

◆ ToArrayAsync< T >() [3/3]

async Task< T[]> PeanutButter.Utils.AsyncExtensionsForIEnumerables.ToArrayAsync< T > ( this Task< T[]> src)
static

Allows awaiting on making an async result of IEnumerable<T> into an array. Think of "ToArray" for an async result.

Template Parameters
T
Parameters
src
Returns

◆ WhereAsync< T >()

async Task< IEnumerable< T > > PeanutButter.Utils.AsyncExtensionsForIEnumerables.WhereAsync< T > ( this IEnumerable< T > src,
Func< T, Task< bool > > discriminator )
static

Provides an awaitable .Where() where your discriminator function can be async. Will return an empty collection if operating on null.

Template Parameters
T
Parameters
srcSource collection
discriminatorDiscriminator function
Returns

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/AsyncExtensionsForIEnumerables.cs