Ver Fonte

Checking for IAsyncPartition in Skip and Take.

Bart De Smet há 8 anos atrás
pai
commit
36316c6385

+ 5 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs

@@ -19,13 +19,17 @@ namespace System.Linq
             {
             {
                 // Return source if not actually skipping, but only if it's a type from here, to avoid
                 // Return source if not actually skipping, but only if it's a type from here, to avoid
                 // issues if collections are used as keys or otherwise must not be aliased.
                 // issues if collections are used as keys or otherwise must not be aliased.
-                if (source is AsyncIterator<TSource>)
+                if (source is AsyncIterator<TSource> || source is IAsyncPartition<TSource>)
                 {
                 {
                     return source;
                     return source;
                 }
                 }
 
 
                 count = 0;
                 count = 0;
             }
             }
+            else if (source is IAsyncPartition<TSource> partition)
+            {
+                return partition.Skip(count);
+            }
 
 
             return new SkipAsyncIterator<TSource>(source, count);
             return new SkipAsyncIterator<TSource>(source, count);
         }
         }

+ 4 - 0
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs

@@ -19,6 +19,10 @@ namespace System.Linq
             {
             {
                 return Empty<TSource>();
                 return Empty<TSource>();
             }
             }
+            else if (source is IAsyncPartition<TSource> partition)
+            {
+                return partition.Take(count);
+            }
 
 
             return new TakeAsyncIterator<TSource>(source, count);
             return new TakeAsyncIterator<TSource>(source, count);
         }
         }