本文整理汇总了C#中Octokit.ApiOptions类的典型用法代码示例。如果您正苦于以下问题:C# ApiOptions类的具体用法?C# ApiOptions怎么用?C# ApiOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApiOptions类属于Octokit命名空间,在下文中一共展示了ApiOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllForGist
/// <summary>
/// Gets all comments for the gist with the specified id.
/// </summary>
/// <remarks>http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist</remarks>
/// <param name="gistId">The id of the gist</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>Task{IReadOnlyList{GistComment}}.</returns>
public Task<IReadOnlyList<GistComment>> GetAllForGist(string gistId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<GistComment>(ApiUrls.GistComments(gistId), options);
}
示例2: GetAll
/// <summary>
/// List a user’s followers
/// </summary>
/// <param name="login">The login name for the user</param>
/// <param name="options">Options for changing the API response</param>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
/// </remarks>
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
public Task<IReadOnlyList<User>> GetAll(string login, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<User>(ApiUrls.Followers(login), options);
}
示例3: GetAll
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAll(owner, name, new CommitRequest(), options);
}
示例4: EnsuresArgumentsNotNull
public async Task EnsuresArgumentsNotNull()
{
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
var options = new ApiOptions();
var request = new RepositoryIssueRequest();
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name").ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name").ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "").ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", options).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null).ToTask());
}
示例5: GetAllForCurrent
/// <summary>
/// Retrieves all of the <see cref="Notification"/>s for the current user.
/// </summary>
/// <param name="request">Specifies the parameters to filter notifications by</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
public Task<IReadOnlyList<Notification>> GetAllForCurrent(NotificationsRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<Notification>(ApiUrls.Notifications(), request.ToParametersDictionary(), options);
}
示例6: ReturnsPageOfIssuesFromStartForARepository
public async Task ReturnsPageOfIssuesFromStartForARepository()
{
var first = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var firstPage = await _issuesClient.GetAllForRepository("libgit2", "libgit2sharp", first);
var second = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var secondPage = await _issuesClient.GetAllForRepository("libgit2", "libgit2sharp", second);
Assert.Equal(5, firstPage.Count);
Assert.Equal(5, secondPage.Count);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
Assert.NotEqual(firstPage[3].Id, secondPage[3].Id);
Assert.NotEqual(firstPage[4].Id, secondPage[4].Id);
}
示例7: ShouldContinue
internal static bool ShouldContinue(
Uri uri,
ApiOptions options)
{
if (uri == null)
{
return false;
}
if (uri.Query.Contains("page=") && options.PageCount.HasValue)
{
var allValues = ToQueryStringDictionary(uri);
string pageValue;
if (allValues.TryGetValue("page", out pageValue))
{
var startPage = options.StartPage ?? 1;
var pageCount = options.PageCount.Value;
var endPage = startPage + pageCount;
if (pageValue.Equals(endPage.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
{
return false;
}
}
}
return true;
}
示例8: GetAll
/// <summary>
/// Gets all verified public keys for a user.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
/// </remarks>
/// <param name="userName">The @ handle of the user.</param>
/// <param name="options">Options to change API's behavior.</param>
/// <returns>Lists the verified public keys for a user.</returns>
public Task<IReadOnlyList<PublicKey>> GetAll(string userName, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(userName, "userName");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<PublicKey>(ApiUrls.Keys(userName), options);
}
示例9: ReturnsCorrectCountOfIssueLabelsWithoutStartForAnIssue
public async Task ReturnsCorrectCountOfIssueLabelsWithoutStartForAnIssue()
{
var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" };
var newLabel = new NewLabel("test label", "FFFFFF");
var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);
var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
var issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
Assert.Empty(issueLabelsInfo);
var issueUpdate = new IssueUpdate();
issueUpdate.AddLabel(label.Name);
var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
Assert.NotNull(updated);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1
};
issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, options);
Assert.Equal(1, issueLabelsInfo.Count);
Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
}
示例10: EnsuresNonNullArguments
public void EnsuresNonNullArguments()
{
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
var options = new ApiOptions();
var request = new RepositoryIssueRequest();
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (RepositoryIssueRequest)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, options));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, request, null));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", options));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", options));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request, options));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options));
}
示例11: GetAll
/// <summary>
/// Gets all <see cref="Release"/>s for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/releases/#list-releases-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public Task<IReadOnlyList<Release>> GetAll(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
var endpoint = ApiUrls.Releases(repositoryId);
return ApiConnection.GetAll<Release>(endpoint, null, AcceptHeaders.StableVersion, options);
}
示例12: GetAll
/// <summary>
/// Gets review comments for a specified pull request.
/// </summary>
/// <remarks>http://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The pull request number</param>
/// <param name="options">Options for changing the API response</param>
public Task<IReadOnlyList<PullRequestReviewComment>> GetAll(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options);
}
示例13: GetAllForIssue
/// <summary>
/// Gets all events for the issue.
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/issues/events/#list-events-for-an-issue
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue number</param>
/// <param name="options">Options for changing the API response</param>
public Task<IReadOnlyList<EventInfo>> GetAllForIssue(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<EventInfo>(ApiUrls.IssuesEvents(owner, name, number), options);
}
示例14: GetAllForRepository
/// <summary>
/// Gets a list of the pull request review comments in a specified repository.
/// </summary>
/// <remarks>http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>The list of <see cref="PullRequestReviewComment"/>s for the specified repository</returns>
public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return GetAllForRepository(owner, name, new PullRequestReviewCommentRequest(), options);
}
示例15: GetAll
/// <summary>
/// Gets all the branches for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#list-branches">API documentation</a> for more details
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public Task<IReadOnlyList<Branch>> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesApiPreview, options);
}