public static AsyncPageable <T> CreateAsyncEnumerable <T>(Func <int?, Task <Page <T> > > firstPageFunc, Func <string?, int?, Task <Page <T> > >?nextPageFunc, int?pageSize = default) where T : notnull
        {
            AsyncPageFunc <T> first = (continuationToken, pageSizeHint) => firstPageFunc(pageSizeHint);
            AsyncPageFunc <T>?next  = nextPageFunc != null ? new AsyncPageFunc <T>(nextPageFunc) : null;

            return(new FuncAsyncPageable <T>(first, next, pageSize));
        }
            public override async IAsyncEnumerable <Page <T> > AsPages(string?continuationToken = default, int?pageSizeHint = default)
            {
                AsyncPageFunc <T> pageFunc = _firstPageFunc;
                int?pageSize = pageSizeHint ?? _defaultPageSize;

                do
                {
                    Page <T> pageResponse = await pageFunc(continuationToken, pageSize).ConfigureAwait(false);

                    yield return(pageResponse);

                    continuationToken = pageResponse.ContinuationToken;
                    pageFunc          = _nextPageFunc;
                } while (continuationToken != null);
            }
            public override async IAsyncEnumerable <Page <T> > AsPages(string?continuationToken = default, int?pageSizeHint = default)
            {
                AsyncPageFunc <T>?pageFunc = string.IsNullOrEmpty(continuationToken) ? _firstPageFunc : _nextPageFunc;

                if (pageFunc == null)
                {
                    yield break;
                }

                int?pageSize = pageSizeHint ?? _defaultPageSize;

                do
                {
                    Page <T> pageResponse = await pageFunc(continuationToken, pageSize).ConfigureAwait(false);

                    yield return(pageResponse);

                    continuationToken = pageResponse.ContinuationToken;
                    pageFunc          = _nextPageFunc;
                } while (!string.IsNullOrEmpty(continuationToken) && pageFunc != null);
            }
 public FuncAsyncPageable(AsyncPageFunc <T> firstPageFunc, AsyncPageFunc <T> nextPageFunc, int?defaultPageSize = default)
 {
     _firstPageFunc   = firstPageFunc;
     _nextPageFunc    = nextPageFunc;
     _defaultPageSize = defaultPageSize;
 }