소스 검색

Check for existing type

Oren Novotny 9 년 전
부모
커밋
c94cff833e
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      Ix.NET/Source/System.Interactive.Async/Cast.cs

+ 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);
         }