Class Paginator
A utility class to compute paging or batching offsets.
Inherited Members
Namespace: Swan
Syntax
public class Paginator
Constructors
Paginator(Int32, Int32)
Initializes a new instance of the Paginator class.
Declaration
public Paginator(int totalCount, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
Int32 | totalCount | The total count of items to page over. |
Int32 | pageSize | The desired size of individual pages. |
Properties
PageCount
Gets the computed number of pages.
Declaration
public int PageCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
PageSize
Gets the desired number of items per page.
Declaration
public int PageSize { get; }
Property Value
Type | Description |
---|---|
Int32 |
TotalCount
Gets the total number of items to page over.
Declaration
public int TotalCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
GetFirstItemIndex(Int32)
Gets the start item index of the given page.
Declaration
public int GetFirstItemIndex(int pageIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pageIndex | Zero-based index of the page. |
Returns
Type | Description |
---|---|
Int32 | The start item index. |
GetItemCount(Int32)
Gets the item count of the given page index.
Declaration
public int GetItemCount(int pageIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pageIndex | Zero-based index of the page. |
Returns
Type | Description |
---|---|
Int32 | The number of items that the page contains. |
GetLastItemIndex(Int32)
Gets the end item index of the given page.
Declaration
public int GetLastItemIndex(int pageIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pageIndex | Zero-based index of the page. |
Returns
Type | Description |
---|---|
Int32 | The end item index. |