2using System.Collections;
3using System.Collections.Generic;
4using System.Threading.Tasks;
17 private IEnumerator<T> currentPageEnumerator;
26 this.currentPage = this.firstPage = FirstPage;
27 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
28 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
37 this.firstPage =
null;
38 this.currentPage =
null;
39 this.currentPageEnumerator = FixedSetOfItems.GetEnumerator();
40 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
46 public T
Current => this.currentPageEnumerator.Current;
51 object IEnumerator.Current => this.currentPageEnumerator.Current;
58 if (this.currentPage is IDisposable Disposable)
61 this.currentPageEnumerator.Dispose();
72 if (this.currentPageEnumerator.MoveNext())
75 if (this.currentPage is
null)
78 if (!this.currentPage.
More)
82 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
83 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
95 if (await this.MoveNextOnCurrentPage())
98 if (this.currentPage is
null)
101 if (!this.currentPage.
More)
105 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
106 this.currentPageEnumeratorAsync = this.currentPageEnumerator as
IAsyncEnumerator;
110 private Task<bool> MoveNextOnCurrentPage()
112 if (this.currentPageEnumeratorAsync is
null)
113 return Task.FromResult(this.currentPageEnumerator.MoveNext());
123 if (this.firstPage is
null)
124 this.currentPageEnumerator.Reset();
127 this.currentPage = this.firstPage;
128 this.currentPageEnumerator = this.currentPage.
Items.GetEnumerator();
129 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.
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 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.