mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-01 10:25:36 +00:00
Rename to Octokit to be consistent with other API libs
GitHub is naming all of the libraries Octokit for their respective platforms
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Http
|
||||
{
|
||||
public class ReadOnlyPagedCollection<T> : ReadOnlyCollection<T>, IReadOnlyPagedCollection<T>
|
||||
{
|
||||
readonly IConnection connection;
|
||||
readonly ApiInfo info;
|
||||
|
||||
public ReadOnlyPagedCollection(IResponse<List<T>> response, IConnection connection)
|
||||
: base(response != null ? response.BodyAsObject : null)
|
||||
{
|
||||
Ensure.ArgumentNotNull(response, "response");
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
|
||||
this.connection = connection;
|
||||
info = response.ApiInfo;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyPagedCollection<T>> GetNextPage()
|
||||
{
|
||||
var nextPageUrl = info.GetNextPageUrl();
|
||||
if (nextPageUrl == null) return null;
|
||||
|
||||
var response = await connection.GetAsync<List<T>>(nextPageUrl);
|
||||
return new ReadOnlyPagedCollection<T>(response, connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user