mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			48 lines
		
	
	
		
			924 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			924 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace Kyoo.Models
 | 
						|
{
 | 
						|
	public class Page<T> where T : IResource
 | 
						|
	{
 | 
						|
		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, 
 | 
						|
			string url,
 | 
						|
			Dictionary<string, string> query,
 | 
						|
			int limit)
 | 
						|
		{
 | 
						|
			Items = items;
 | 
						|
			This = url + query.ToQueryString();
 | 
						|
 | 
						|
			if (items.Count == limit)
 | 
						|
			{
 | 
						|
				query["afterID"] = items.Last().ID.ToString();
 | 
						|
				Next = url + query.ToQueryString();
 | 
						|
			}
 | 
						|
			
 | 
						|
			query.Remove("afterID");
 | 
						|
			First = url + query.ToQueryString();
 | 
						|
		}
 | 
						|
	}
 | 
						|
} |