Prechádzať zdrojové kódy

Check for existing type

Oren Novotny 9 rokov pred
rodič
commit
c94cff833e

+ 7 - 0
Ix.NET/Source/System.Interactive.Async/Cast.cs

@@ -16,6 +16,13 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
+            // Check to see if it already is and short-circuit
+            var typedSource = source as IAsyncEnumerable<TResult>;
+            if (typedSource != null)
+            {
+                return typedSource;
+            }
+
             return source.Select(x => (TResult)x);
         }