AsyncQueryableEx.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. using System.Linq.Expressions;
  6. using System.Reflection;
  7. namespace System.Linq
  8. {
  9. /// <summary>
  10. /// Provides a set of extension methods for asynchronous enumerable sequences represented using expression trees.
  11. /// </summary>
  12. [LocalQueryMethodImplementationType(typeof(AsyncEnumerableEx))]
  13. public static partial class AsyncQueryableEx
  14. {
  15. private static Expression GetSourceExpression<TSource>(IAsyncEnumerable<TSource> source)
  16. {
  17. if (source is IAsyncQueryable<TSource> queryable)
  18. {
  19. return queryable.Expression;
  20. }
  21. return Expression.Constant(source, typeof(IAsyncEnumerable<TSource>));
  22. }
  23. internal static MethodInfo InfoOf<R>(Expression<Func<R>> f)
  24. {
  25. return ((MethodCallExpression)f.Body).Method;
  26. }
  27. }
  28. }