mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
50 lines
938 B
C#
50 lines
938 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Kyoo.Models
|
|
{
|
|
public class Page<T>
|
|
{
|
|
public string This { get; set; }
|
|
public string First { get; set; }
|
|
public string Next { get; set; }
|
|
|
|
public int Count => Items.Count;
|
|
public ICollection<T> Items { get; set; }
|
|
|
|
public Page() { }
|
|
|
|
public Page(ICollection<T> items)
|
|
{
|
|
Items = items;
|
|
}
|
|
|
|
public Page(ICollection<T> items, string @this, string next, string first)
|
|
{
|
|
Items = items;
|
|
This = @this;
|
|
Next = next;
|
|
First = first;
|
|
}
|
|
|
|
public Page(ICollection<T> items,
|
|
Func<T, string> getID,
|
|
string url,
|
|
Dictionary<string, string> query,
|
|
int limit)
|
|
{
|
|
Items = items;
|
|
This = url + query.ToQueryString();
|
|
|
|
if (items.Count == limit)
|
|
{
|
|
query["afterID"] = getID(items.Last());
|
|
Next = url + query.ToQueryString();
|
|
}
|
|
|
|
query.Remove("afterID");
|
|
First = url + query.ToQueryString();
|
|
}
|
|
}
|
|
} |