|
@@ -10,54 +10,45 @@ namespace System.Linq
|
|
|
{
|
|
|
public static partial class AsyncEnumerable
|
|
|
{
|
|
|
- public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
|
|
|
+ public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value)
|
|
|
{
|
|
|
if (source == null)
|
|
|
- {
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- }
|
|
|
|
|
|
+ return ContainsCore(source, value, EqualityComparer<TSource>.Default, CancellationToken.None);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
|
|
|
+ {
|
|
|
+ if (source == null)
|
|
|
+ throw new ArgumentNullException(nameof(source));
|
|
|
if (comparer == null)
|
|
|
- {
|
|
|
throw new ArgumentNullException(nameof(comparer));
|
|
|
- }
|
|
|
|
|
|
- return Contains(source, value, comparer, CancellationToken.None);
|
|
|
+ return ContainsCore(source, value, comparer, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
- public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value)
|
|
|
+ public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
- {
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- }
|
|
|
|
|
|
- return Contains(source, value, CancellationToken.None);
|
|
|
+ return ContainsCore(source, value, EqualityComparer<TSource>.Default, cancellationToken);
|
|
|
}
|
|
|
|
|
|
public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
|
- {
|
|
|
throw new ArgumentNullException(nameof(source));
|
|
|
- }
|
|
|
-
|
|
|
if (comparer == null)
|
|
|
- {
|
|
|
throw new ArgumentNullException(nameof(comparer));
|
|
|
- }
|
|
|
|
|
|
- return source.Any(x => comparer.Equals(x, value), cancellationToken);
|
|
|
+ return ContainsCore(source, value, comparer, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, CancellationToken cancellationToken)
|
|
|
+ private static Task<bool> ContainsCore<TSource>(IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- if (source == null)
|
|
|
- {
|
|
|
- throw new ArgumentNullException(nameof(source));
|
|
|
- }
|
|
|
-
|
|
|
- return source.Contains(value, EqualityComparer<TSource>.Default, cancellationToken);
|
|
|
+ return source.Any(x => comparer.Equals(x, value), cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
}
|