Added HasNextPage and HasPreviousPage to Paging-Objects.

Renamed Next and Previous to GetNextPage and GetPreviousPage
This commit is contained in:
Johnny @PC 2015-11-07 20:18:39 +01:00
parent 095967ff4b
commit 323561909e
2 changed files with 31 additions and 3 deletions

View File

@ -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;
}
}
}

View File

@ -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)