Exemple #1
0
        private static async Task <(int, ReadFeedCrossFeedRangeState?)> DrainAllAsync(IAsyncEnumerable <TryCatch <ReadFeedPage> > asyncEnumerable)
        {
            ReadFeedCrossFeedRangeState?state = default;
            int totalCount = 0;

            await foreach (TryCatch <ReadFeedPage> monadicPage in asyncEnumerable)
            {
                monadicPage.ThrowIfFailed();

                ReadFeedPage page = monadicPage.Result;
                state       = page.State;
                totalCount += page.Documents.Count;
            }

            return(totalCount, state);
        }
Exemple #2
0
        private static async Task <(int, ReadFeedCrossFeedRangeState?)> DrainOnePageAsync(IAsyncEnumerable <TryCatch <ReadFeedPage> > asyncEnumerable)
        {
            IAsyncEnumerator <TryCatch <ReadFeedPage> > enumerator = asyncEnumerable.GetAsyncEnumerator();

            await enumerator.MoveNextAsync();

            TryCatch <ReadFeedPage> monadicPage = enumerator.Current;

            monadicPage.ThrowIfFailed();

            ReadFeedPage page = monadicPage.Result;
            ReadFeedCrossFeedRangeState?state = page.State;
            int totalCount = page.Documents.Count;

            return(totalCount, state);
        }