* Update all dependencies and deal with warning/errors * Add updated AsyncEnumerable implementation * Fix broken target * Cleanup * Remove obsolete message * typo * Update azure pipelines * Update samples to .NET Core 3.0 * Pull out test change * Install the .net core 3 SDK on the ubuntu image for the time being * Target net core 3 for the unit tests because pipelines
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Discord
|
|
{
|
|
/// <summary> An extension class for squashing <see cref="IAsyncEnumerable{T}"/>. </summary>
|
|
/// <remarks>
|
|
/// This set of extension methods will squash an <see cref="IAsyncEnumerable{T}"/> into a
|
|
/// single <see cref="IEnumerable{T}"/>. This is often associated with requests that has a
|
|
/// set limit when requesting.
|
|
/// </remarks>
|
|
public static class AsyncEnumerableExtensions
|
|
{
|
|
/// <summary> Flattens the specified pages into one <see cref="IEnumerable{T}"/> asynchronously. </summary>
|
|
public static async Task<IEnumerable<T>> FlattenAsync<T>(this IAsyncEnumerable<IEnumerable<T>> source)
|
|
{
|
|
return await source.Flatten().ToArrayAsync().ConfigureAwait(false);
|
|
}
|
|
/// <summary> Flattens the specified pages into one <see cref="IAsyncEnumerable{T}"/>. </summary>
|
|
public static IAsyncEnumerable<T> Flatten<T>(this IAsyncEnumerable<IEnumerable<T>> source)
|
|
{
|
|
return source.SelectMany(enumerable => enumerable.ToAsyncEnumerable());
|
|
}
|
|
}
|
|
}
|