Add new Hcs.Broker to communicate with ГИС ЖКХ via CryptoPro LibCore
This commit is contained in:
52
Hcs.Broker/Api/Request/PaginationData.cs
Normal file
52
Hcs.Broker/Api/Request/PaginationData.cs
Normal file
@ -0,0 +1,52 @@
|
||||
namespace Hcs.Broker.Api.Request
|
||||
{
|
||||
internal class PaginationData
|
||||
{
|
||||
/// <summary>
|
||||
/// Состояние, указывающее на то, что это последняя страница
|
||||
/// </summary>
|
||||
internal bool IsLastPage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор следующей страницы
|
||||
/// </summary>
|
||||
internal Guid NextGuid { get; private set; }
|
||||
|
||||
public PaginationData(object item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new System.Exception($"[{nameof(PaginationData)}] item is null");
|
||||
}
|
||||
else if (item is bool boolItem)
|
||||
{
|
||||
if (boolItem == false)
|
||||
{
|
||||
throw new System.Exception($"[{nameof(PaginationData)}] item is false");
|
||||
}
|
||||
|
||||
IsLastPage = true;
|
||||
}
|
||||
else if (item is string stringItem)
|
||||
{
|
||||
IsLastPage = false;
|
||||
NextGuid = Guid.Parse(stringItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception($"[{nameof(PaginationData)}] failed to handle item of {item.GetType().FullName} type");
|
||||
}
|
||||
}
|
||||
|
||||
internal static PaginationData CreateLastPageData()
|
||||
{
|
||||
return new PaginationData(true);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{nameof(PaginationData)}] {nameof(IsLastPage)} = {IsLastPage}" +
|
||||
(IsLastPage ? "" : $", {nameof(NextGuid)} = {NextGuid}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user