mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 06:56:27 +00:00
Added HasNextPage and HasPreviousPage to Paging-Objects.
Renamed Next and Previous to GetNextPage and GetPreviousPage
This commit is contained in:
parent
095967ff4b
commit
323561909e
@ -26,5 +26,15 @@ namespace SpotifyAPI.Web.Models
|
||||
|
||||
[JsonProperty("total")]
|
||||
public int Total { get; set; }
|
||||
|
||||
public bool HasNextPage()
|
||||
{
|
||||
return Next != null;
|
||||
}
|
||||
|
||||
public bool HasPreviousPage()
|
||||
{
|
||||
return Next != null;
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ namespace SpotifyAPI.Web
|
||||
public void Dispose()
|
||||
{
|
||||
WebClient.Dispose();
|
||||
GC.SuppressFinalize(this); //TODO
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#region Search
|
||||
@ -1450,16 +1450,34 @@ namespace SpotifyAPI.Web
|
||||
|
||||
#region Util
|
||||
|
||||
public Paging<T> Next<T>(Paging<T> paging)
|
||||
public Paging<T> GetNextPage<T>(Paging<T> paging)
|
||||
{
|
||||
if (!paging.HasNextPage())
|
||||
throw new InvalidOperationException("This Paging-Object has no Next-Page");
|
||||
return DownloadData<Paging<T>>(paging.Next);
|
||||
}
|
||||
|
||||
public Paging<T> Previous<T>(Paging<T> paging)
|
||||
public async Task<Paging<T>> GetNextPageAsync<T>(Paging<T> paging)
|
||||
{
|
||||
if (!paging.HasNextPage())
|
||||
throw new InvalidOperationException("This Paging-Object has no Next-Page");
|
||||
return await DownloadDataAsync<Paging<T>>(paging.Next);
|
||||
}
|
||||
|
||||
public Paging<T> GetPreviousPage<T>(Paging<T> paging)
|
||||
{
|
||||
if (!paging.HasPreviousPage())
|
||||
throw new InvalidOperationException("This Paging-Object has no Previous-Page");
|
||||
return DownloadData<Paging<T>>(paging.Previous);
|
||||
}
|
||||
|
||||
public async Task<Paging<T>> GetPreviousPageAsync<T>(Paging<T> paging)
|
||||
{
|
||||
if (!paging.HasPreviousPage())
|
||||
throw new InvalidOperationException("This Paging-Object has no Previous-Page");
|
||||
return await DownloadDataAsync<Paging<T>>(paging.Previous);
|
||||
}
|
||||
|
||||
public T UploadData<T>(String url, String uploadData, String method = "POST")
|
||||
{
|
||||
if (!UseAuth)
|
||||
|
Loading…
Reference in New Issue
Block a user