|
@@ -10,6 +10,14 @@ namespace System.Linq
|
|
|
{
|
|
|
public static partial class AsyncEnumerable
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="int" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="int" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double> AverageAsync(this IAsyncEnumerable<int> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -42,6 +50,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -146,6 +165,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="long" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="long" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double> AverageAsync(this IAsyncEnumerable<long> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -178,6 +205,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -282,6 +320,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="float" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="float" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<float> AverageAsync(this IAsyncEnumerable<float> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -314,6 +360,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="float" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<float> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -418,6 +475,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="double" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="double" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double> AverageAsync(this IAsyncEnumerable<double> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -450,6 +515,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -554,6 +630,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="decimal" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="decimal" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<decimal> AverageAsync(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -586,6 +670,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<decimal> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -690,6 +785,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="Nullable{Int}" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="Nullable{Int}" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double?> AverageAsync(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -730,6 +833,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="Nullable{Int}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double?> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -858,6 +972,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="Nullable{Long}" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="Nullable{Long}" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double?> AverageAsync(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -898,6 +1020,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="Nullable{Long}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double?> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1026,6 +1159,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="Nullable{Float}" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="Nullable{Float}" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<float?> AverageAsync(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1066,6 +1207,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="Nullable{Float}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<float?> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1194,6 +1346,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="Nullable{Double}" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="Nullable{Double}" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<double?> AverageAsync(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1234,6 +1394,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="Nullable{Double}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<double?> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1362,6 +1533,14 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of <see cref="Nullable{Decimal}" /> values.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">A sequence of <see cref="Nullable{Decimal}" /> values to calculate the average of.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
public static ValueTask<decimal?> AverageAsync(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1402,6 +1581,17 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Computes the average of an async-enumerable sequence of nullable <see cref="Nullable{Decimal}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">A sequence of values to calculate the average of.</param>
|
|
|
+ /// <param name="selector">A transform function to apply to each element.</param>
|
|
|
+ /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
+ /// <returns>An async-enumerable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
+ /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
|
|
|
+ /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
public static ValueTask<decimal?> AverageAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|