|
@@ -18,17 +18,15 @@ namespace System.Linq
|
|
|
return First(source, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
+ public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- if (predicate == null)
|
|
|
- throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return First(source, predicate, CancellationToken.None);
|
|
|
+ return First_(source, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
+ public static Task<TSource> First<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 First(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> First<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 First_(source, cancellationToken);
|
|
|
+ return source.Where(predicate).First(cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> First<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).First(cancellationToken);
|
|
|
+ return First(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
|
|
@@ -74,17 +74,15 @@ namespace System.Linq
|
|
|
return FirstOrDefault(source, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
+ public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- if (predicate == null)
|
|
|
- throw new ArgumentNullException(nameof(predicate));
|
|
|
|
|
|
- return FirstOrDefault(source, predicate, CancellationToken.None);
|
|
|
+ return FirstOrDefault_(source, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
|
|
|
+ public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
|
|
|
{
|
|
|
if (source == null)
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
@@ -94,22 +92,24 @@ namespace System.Linq
|
|
|
return FirstOrDefault(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> FirstOrDefault<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 FirstOrDefault_(source, cancellationToken);
|
|
|
+ return source.Where(predicate).FirstOrDefault(cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
|
|
|
+ public static Task<TSource> FirstOrDefault<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).FirstOrDefault(cancellationToken);
|
|
|
+ return FirstOrDefault(source, predicate, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
|