4using System.Threading.Tasks;
18 private IEnumerator<T> currentPageEnumerator;
27 this.currentPage = this.firstPage = FirstPage;
28 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
29 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
38 this.firstPage =
null;
39 this.currentPage =
null;
40 this.currentPageEnumerator = FixedSetOfItems.GetEnumerator();
41 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
47 public T
Current => this.currentPageEnumerator.Current;
52 object IEnumerator.Current => this.currentPageEnumerator.Current;
57 [Obsolete(
"Use DisposeAsync() instead.")]
69 await DisposableAsync.DisposeAsync();
70 else if (this.currentPage is IDisposable Disposable)
74 await DisposableAsync2.DisposeAsync();
76 this.currentPageEnumerator.Dispose();
87 if (this.currentPageEnumerator.MoveNext())
90 if (this.currentPage is
null)
93 if (!this.currentPage.
More)
97 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
98 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
110 if (await this.MoveNextOnCurrentPage())
113 if (this.currentPage is
null)
116 if (!this.currentPage.
More)
120 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
121 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
125 private Task<bool> MoveNextOnCurrentPage()
127 if (this.currentPageEnumeratorAsync is
null)
128 return Task.FromResult(this.currentPageEnumerator.MoveNext());
138 if (this.firstPage is
null)
139 this.currentPageEnumerator.Reset();
142 this.currentPage = this.firstPage;
143 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
144 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IPage< object > > FindNext(IPage< object > Page)
Finds the next page of objects in a given collection.
Paginated object enumerator.
async Task DisposeAsync()
IDisposableAsync.DisposeAsync
void Reset()
Resets the enumerator.
bool MoveNext()
Moves to next item.
async Task< bool > MoveNextAsync()
Moves to next item.
PaginatedEnumerator(IEnumerable< T > FixedSetOfItems)
Paginated object enumerator, enumerating a single page of enumerable items.
void Dispose()
IDisposable.Dispose
PaginatedEnumerator(IPage< T > FirstPage)
Paginated object enumerator.
Interface for asynchronously disposable objects.
Interface for asynchronous enumerators.
Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.
Interface for paginated results.
IEnumerable< T > Items
Items available in the page. The enumeration may be empty.
bool More
If there may be more pages following this page.