AsyncQueryableEx.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  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. public static partial class AsyncQueryableEx
  13. {
  14. private static Expression GetSourceExpression<TSource>(IAsyncEnumerable<TSource> source)
  15. {
  16. if (source is IAsyncQueryable<TSource> queryable)
  17. {
  18. return queryable.Expression;
  19. }
  20. return Expression.Constant(source, typeof(IAsyncEnumerable<TSource>));
  21. }
  22. internal static MethodInfo InfoOf<R>(Expression<Func<R>> f)
  23. {
  24. return ((MethodCallExpression)f.Body).Method;
  25. }
  26. }
  27. }