mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
553 B
22 lines
553 B
using System; |
|
|
|
namespace ErsatzTV.Core; |
|
|
|
public static class PaginationOptions |
|
{ |
|
public const int DefaultPageSize = 100; |
|
public const int MaxPageSize = 1000; |
|
|
|
public static int NormalizePageSize(int? requested) => |
|
NormalizePageSize(requested, DefaultPageSize, MaxPageSize); |
|
|
|
public static int NormalizePageSize(int? requested, int defaultSize, int maxSize) |
|
{ |
|
if (requested is null || requested <= 0) |
|
{ |
|
return defaultSize; |
|
} |
|
|
|
return Math.Clamp(requested.Value, 1, maxSize); |
|
} |
|
}
|
|
|