소스 검색

Minor tweaks to Any and All.

Bart De Smet 7 년 전
부모
커밋
5eed2806db
2개의 변경된 파일11개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs
  2. 9 4
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return All(source, predicate, CancellationToken.None);
+            return AllCore(source, predicate, CancellationToken.None);
         }
 
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
@@ -27,7 +27,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return All(source, predicate, CancellationToken.None);
+            return AllCore(source, predicate, CancellationToken.None);
         }
 
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)

+ 9 - 4
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return Any(source, predicate, CancellationToken.None);
+            return AnyCore(source, predicate, CancellationToken.None);
         }
 
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
@@ -27,7 +27,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return Any(source, predicate, CancellationToken.None);
+            return AnyCore(source, predicate, CancellationToken.None);
         }
 
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source)
@@ -35,7 +35,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return Any(source, CancellationToken.None);
+            return AnyCore(source, CancellationToken.None);
         }
 
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
@@ -58,11 +58,16 @@ namespace System.Linq
             return AnyCore(source, predicate, cancellationToken);
         }
 
-        public static async Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
+        public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
+            return AnyCore(source, cancellationToken);
+        }
+
+        private static async Task<bool> AnyCore<TSource>(IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
+        {
             var e = source.GetAsyncEnumerator(cancellationToken);
 
             try