| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Threading; |
| | 3 | | using System.Threading.Tasks; |
| | 4 | |
|
| | 5 | | namespace SharpHoundCommonLib; |
| | 6 | |
|
| | 7 | | public static class AsyncEnumerable { |
| 10 | 8 | | public static IAsyncEnumerable<T> Empty<T>() => EmptyAsyncEnumerable<T>.Instance; |
| | 9 | |
|
| | 10 | | private sealed class EmptyAsyncEnumerable<T> : IAsyncEnumerable<T> { |
| 3 | 11 | | public static readonly EmptyAsyncEnumerable<T> Instance = new(); |
| 3 | 12 | | private readonly IAsyncEnumerator<T> _enumerator = new EmptyAsyncEnumerator<T>(); |
| 10 | 13 | | public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = new CancellationToken()) { |
| 10 | 14 | | return _enumerator; |
| 10 | 15 | | } |
| | 16 | | } |
| | 17 | |
|
| | 18 | | private sealed class EmptyAsyncEnumerator<T> : IAsyncEnumerator<T> { |
| 10 | 19 | | public ValueTask DisposeAsync() => default; |
| 10 | 20 | | public ValueTask<bool> MoveNextAsync() => new(false); |
| 0 | 21 | | public T Current => default; |
| | 22 | | } |
| | 23 | | } |