AsyncIterator.Opt.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Linq
  8. {
  9. partial class AsyncIterator<TSource>
  10. {
  11. public virtual IAsyncEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
  12. {
  13. return new AsyncEnumerable.SelectEnumerableAsyncIterator<TSource, TResult>(this, selector);
  14. }
  15. public virtual IAsyncEnumerable<TResult> Select<TResult>(Func<TSource, Task<TResult>> selector)
  16. {
  17. return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask<TSource, TResult>(this, selector);
  18. }
  19. public virtual IAsyncEnumerable<TSource> Where(Func<TSource, bool> predicate)
  20. {
  21. return new AsyncEnumerable.WhereEnumerableAsyncIterator<TSource>(this, predicate);
  22. }
  23. public virtual IAsyncEnumerable<TSource> Where(Func<TSource, Task<bool>> predicate)
  24. {
  25. return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask<TSource>(this, predicate);
  26. }
  27. }
  28. }