|
|
@@ -18,17 +18,15 @@ namespace System.Linq
|
|
|
return Last(source, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
+ public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- if (predicate == null)
|
|
|
- throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return Last(source, predicate, CancellationToken.None);
|
|
|
+ return Last_(source, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
+ public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
@@ -38,22 +36,24 @@ namespace System.Linq
|
|
|
return Last(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
+ if (predicate == null)
|
|
|
+ throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return Last_(source, cancellationToken);
|
|
|
+ return source.Where(predicate).Last(cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
if (predicate == null)
|
|
|
throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return source.Where(predicate).Last(cancellationToken);
|
|
|
+ return Last(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
|
|
|
@@ -74,17 +74,15 @@ namespace System.Linq
|
|
|
return LastOrDefault(source, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
+ public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- if (predicate == null)
|
|
|
- throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return LastOrDefault(source, predicate, CancellationToken.None);
|
|
|
+ return LastOrDefault_(source, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
+ public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
@@ -94,23 +92,24 @@ namespace System.Linq
|
|
|
return LastOrDefault(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
+ if (predicate == null)
|
|
|
+ throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return LastOrDefault_(source, cancellationToken);
|
|
|
+ return source.Where(predicate).LastOrDefault(cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
if (predicate == null)
|
|
|
throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return source.Where(predicate)
|
|
|
- .LastOrDefault(cancellationToken);
|
|
|
+ return LastOrDefault(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
|