private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipWhileContext <TSource> context) { try { var yielding = false; while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (!yielding && !context.Predicate(context.Source.Current)) { yielding = true; } if (yielding) { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipContext <TSource> context) { try { var itemsToSkip = context.Count; while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (itemsToSkip > 0) { itemsToSkip--; } else { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }
private static async Task _enumerate(AsyncEnumerator <TResult> .Yield yield, SelectContext <TSource, TResult> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { await yield.ReturnAsync(context.Selector(enumerator.Current)).ConfigureAwait(false); } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, WhereContext <TSource> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (context.Predicate(enumerator.Current)) { await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false); } } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, TakeContext <TSource> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { for (var i = context.Count; i > 0; i--) { if (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false); } } } }
private static async Task _enumerate(AsyncEnumerator <TResult> .Yield yield, SelectContext <TSource, TResult> context) { try { while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { await yield.ReturnAsync(context.Selector(context.Source.Current)).ConfigureAwait(false); } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipContext <TSource> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { var itemsToSkip = context.Count; while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (itemsToSkip > 0) { itemsToSkip--; } else { await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false); } } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipWhileContext <TSource> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { var yielding = false; while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (!yielding && !context.Predicate(enumerator.Current)) { yielding = true; } if (yielding) { await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false); } } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, TakeContext <TSource> context) { try { for (var i = context.Count; i > 0; i--) { if (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, WhereWithIndexContext <TSource> context) { try { long index = 0; while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (context.Predicate(context.Source.Current, index)) { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } index++; } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, TakeWhileContext <TSource> context) { try { while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (context.Predicate(context.Source.Current)) { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } else { break; } } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }