Skip to content

Pagination

Namespace: SideXP.Core

public struct Pagination

Utility class for pagination system.

Constructors

Pagination(int)

public Pagination(int page)

Class constructor.

Parameters

  • page: The current page index.

Pagination(int, int)

public Pagination(int page, int nbElementsPerPage)

Class constructor.

Parameters

  • page: The current page index.
  • nbElementsPerPage: The number of elements per page.

Pagination(int, int, int)

public Pagination(int page, int nbElementsPerPage, int nbElements)

Class constructor.

Parameters

  • page: The current page index.
  • nbElementsPerPage: The number of elements displayed per page.
  • nbElements: The number of elements in your paginated ensemble.

Fields

DefaultElementsCountPerPage

public const int DefaultElementsCountPerPage = 25

Properties

Page

public int Page

Gets/sets the current page index (starting at 0).

PagesCount

public int PagesCount

Gets the number of pages.

ElementsCount

public int ElementsCount

Gets/sets the total number of elements.

NbElementsPerPage

public int NbElementsPerPage

Gets/sets the number of elements per page.

FirstIndex

public int FirstIndex

Gets the first index (inclusive) in the paginated range.

LastIndex

public int LastIndex

Gets the last index (exclusive) in the paginated range.

Methods

Paginate<T>(IList<T>, int, int)

public static T[] Paginate<T>(IList<T> list, int page, int nbElementsPerPage = 25)

Creates a sub-list of the given one that contains only the elements in the paginated range.

Type parameters

  • T: The type of elements in the given list.

Parameters

  • page: The current page index.
  • nbElementsPerPage: The number of elements per page.
  • list: The list that is paginated.

Returns

Returns the sub-list of the elements to display.

Paginate<T>(IList<T>, Pagination, int, int)

public static T[] Paginate<T>(IList<T> list, out Pagination pagination, int page, int nbElementsPerPage = 25)

Parameters

  • pagination: Outputs the Pagination infos of the operation.
  • page: The current page index.
  • nbElementsPerPage: The number of elements per page.

Paginate<T>(IList<T>)

public T[] Paginate<T>(IList<T> list)

Creates a sub-list of the given one that contains only the elements in the paginated range.

Type parameters

  • T: The type of elements in the given list.

Parameters

  • list: The list that is paginated.

Returns

Returns the sub-list of the elements to display.

CountPages<T>(IList<T>, int)

public static int CountPages<T>(IList<T> list, int nbElementsPerPage = 25)

Computes the number of pages, given the total number of elements and the number of elements per page.

Type parameters

  • T: The types of elements in the given list.

Parameters

  • list: The list that is paginated.
  • nbElementsPerPage: The number of elements displayed per page.

Returns

Returns the computed number of pages.

CountPages(int, int)

public static int CountPages(int elementsCount, int nbElementsPerPage = 25)

Computes the number of pages, given the total number of elements and the number of elements per page.

Parameters

  • elementsCount: The total number of elements.
  • nbElementsPerPage: The number of elements displayed per page.

Returns

Returns the computed number of pages.

operator ==(Pagination, Pagination)

public static bool operator ==(Pagination a, Pagination b)

Checks if the given Pagination values are equal.

operator !=(Pagination, Pagination)

public static bool operator !=(Pagination a, Pagination b)

Checks if the given Pagination are different.

operator ++(Pagination)

public static Pagination operator ++(Pagination pagination)

Increment the current page index.

operator --(Pagination)

public static Pagination operator --(Pagination pagination)

Decrement the current page index.

operator +(Pagination, int)

public static Pagination operator +(Pagination pagination, int nbPagesNext)

Increment the current page index by the given value.

operator -(Pagination, int)

public static Pagination operator -(Pagination pagination, int nbPagesPrevious)

Decrement the current page index by the given value.

Equals(object)

public override bool Equals(object other)

Checks if the given object is equal to this Pagination object.

GetHashCode()

public override int GetHashCode()

Gets the hash code of this Pagination object.

ToString()

public override string ToString()

Converts this Pagination object into a string.