// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(int?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(int?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(long?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(long?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(float?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(float?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(double?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(double?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(decimal?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(decimal?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Max(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(int?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(int?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(long?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(long?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(float?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(float?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(double?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(double?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(decimal?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Aggregate(default(decimal?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return source.Select(selector).Min(cancellationToken); } private static T? NullableMax(T? x, T? y) where T : struct, IComparable { if (!x.HasValue) return y; if (!y.HasValue) return x; if (x.Value.CompareTo(y.Value) >= 0) return x; return y; } private static T? NullableMin(T? x, T? y) where T : struct, IComparable { if (!x.HasValue) return y; if (!y.HasValue) return x; if (x.Value.CompareTo(y.Value) <= 0) return x; return y; } } }