當前位置: 首頁>>代碼示例>>C#>>正文


C# ApiOptions類代碼示例

本文整理匯總了C#中ApiOptions的典型用法代碼示例。如果您正苦於以下問題:C# ApiOptions類的具體用法?C# ApiOptions怎麽用?C# ApiOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApiOptions類屬於命名空間,在下文中一共展示了ApiOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReturnsDistinctEventsBasedOnStartPage

            public async Task ReturnsDistinctEventsBasedOnStartPage()
            {
                var startOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1
                };

                var firstEventsPage = await _eventsClient.GetAll(startOptions).ToList();

                var skipStartOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1,
                    StartPage = 2
                };

                var secondEventsPage = await _eventsClient.GetAll(skipStartOptions).ToList();

                Assert.NotEqual(firstEventsPage[0].Id, secondEventsPage[0].Id);
                Assert.NotEqual(firstEventsPage[1].Id, secondEventsPage[1].Id);
                Assert.NotEqual(firstEventsPage[2].Id, secondEventsPage[2].Id);
                Assert.NotEqual(firstEventsPage[3].Id, secondEventsPage[3].Id);
                Assert.NotEqual(firstEventsPage[4].Id, secondEventsPage[4].Id);
            }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:25,代碼來源:ObservableEventsClientTests.cs

示例2: 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 IObservable<PublicKey> GetAll(string userName, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(userName, "userName");
            Ensure.ArgumentNotNull(options, "options");

            return _client.GetAll(userName, options).ToObservable().SelectMany(k => k);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:16,代碼來源:ObservableUserKeysClient.cs

示例3: 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="IObservable{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
        public IObservable<User> GetAll(string login, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<User>(ApiUrls.Followers(login), options);
        }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:16,代碼來源:ObservableFollowersClient.cs

示例4: FileUpload

 /// <summary>
 /// Creates a new instance of FileUpload for uploading a file to appacitive.
 /// </summary>
 /// <param name="mimeType">The mime type for the file to be uploaded.</param>
 /// <param name="filename">Name of the file to be downloaded. This name should match the name of the file on Appacitive.</param>
 /// <param name="expiryInMinutes">The duration in minutes for which the upload session would be valid. After this duration, this object cannot be used to upload a file.</param>
 /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
 public FileUpload(string mimeType, string filename = null, int expiryInMinutes = 5, ApiOptions options = null)
 {
     this.MimeType = mimeType;
     this.FileName = filename;
     this.FileHandler = ObjectFactory.Build<IHttpFileHandler>();
     this.CacheControlMaxAge = TimeSpan.MinValue;
 }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:14,代碼來源:FileUpload.cs

示例5: GetAll

        /// <summary>
        /// <para>
        /// List all users who are members of an organization. A member is a user that
        /// belongs to at least 1 team in the organization.
        /// </para>
        /// <para>
        /// If the authenticated user is also an owner of this organization then both
        /// concealed and public member will be returned.
        /// </para>
        /// <para>
        /// If the requester is not an owner of the organization the query will be redirected
        /// to the public members list.
        /// </para>
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/orgs/members/#members-list">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="org">The login for the organization</param>
        /// <param name="options">Options for changing the API response</param>
        /// <returns></returns>
        public IObservable<User> GetAll(string org, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, "org");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<User>(ApiUrls.Members(org), options);
        }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:28,代碼來源:ObservableOrganizationMembersClient.cs

示例6: GetAll

        /// <summary>
        /// Returns all <see cref="Team" />s for the current org.
        /// </summary>
        /// <param name="org">Organization to list all teams of.</param>
        /// <param name="options">Options to change API behaviour.</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
        public IObservable<Team> GetAll(string org, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, "org");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<Team>(ApiUrls.OrganizationTeams(org), options);
        }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:14,代碼來源:ObservableTeamsClient.cs

示例7: 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>IObservable{GistComment}.</returns>
        public IObservable<GistComment> GetAllForGist(string gistId, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<GistComment>(ApiUrls.GistComments(gistId), options);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:14,代碼來源:ObservableGistCommentsClient.cs

示例8: ReturnsDistinctResultsBasedOnStartPage

            public async Task ReturnsDistinctResultsBasedOnStartPage()
            {
                var startOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1
                };

                var firstPage = await _releaseClient.GetAll(owner, name, startOptions).ToList();

                var skipStartOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1,
                    StartPage = 2
                };

                var secondPage = await _releaseClient.GetAll(owner, name, skipStartOptions).ToList();

                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);
            }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:25,代碼來源:ObservableReleaseClientTests.cs

示例9: ReturnsDistinctResultsBasedOnStartPage

            public async Task ReturnsDistinctResultsBasedOnStartPage()
            {
                var github = Helper.GetAuthenticatedClient();

                var client = new ObservableRepositoryHooksClient(github);

                var startOptions = new ApiOptions
                {
                    PageSize = 2,
                    PageCount = 1
                };

                var firstPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions).ToList();

                var skipStartOptions = new ApiOptions
                {
                    PageSize = 2,
                    PageCount = 1,
                    StartPage = 2
                };

                var secondPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions).ToList();

                Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
                Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
            }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:26,代碼來源:ObservableRepositoryHooksClientTests.cs

示例10: ReturnsDistinctForksBasedOnStartPage

            public async Task ReturnsDistinctForksBasedOnStartPage()
            {
                var github = Helper.GetAuthenticatedClient();

                var startOptions = new ApiOptions
                {
                    PageCount = 1,
                    PageSize = 3,
                    StartPage = 1
                };

                var firstPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", startOptions);

                var skipStartOptions = new ApiOptions
                {
                    PageCount = 1,
                    PageSize = 3,
                    StartPage = 2
                };

                var secondPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", skipStartOptions);

                Assert.Equal(3, firstPage.Count);
                Assert.Equal(3, 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);
            }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:28,代碼來源:RepositoryForksClientTests.cs

示例11: GetAll

        /// <summary>
        /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
        /// a tag name.
        /// </summary>
        /// <remarks>Only users with pull access can see this.</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for</param>
        /// <param name="options">Options for changing the API response</param>
        public IObservable<CommitStatus> GetAll(int repositoryId, string reference, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<CommitStatus>(ApiUrls.CommitStatuses(repositoryId, reference), options);
        }
開發者ID:rlugojr,項目名稱:octokit.net,代碼行數:15,代碼來源:ObservableCommitStatusClient.cs

示例12: RequestsCorrectUrlWithApiOptions

            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var result = new List<EventInfo> { new EventInfo() };

                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableIssuesEventsClient(gitHubClient);
                
                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
                    new Response
                    {
                        ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
                    }, result);
                gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
                    .Returns(Task.FromResult(response));

                var eventInfos = await client.GetAllForIssue("fake", "repo", 42, options).ToList();

                connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
                Assert.Equal(1, eventInfos.Count);
            }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:28,代碼來源:ObservableIssuesEventsClientTests.cs

示例13: ReturnsDistinctResultsBasedOnStartPage

            public async Task ReturnsDistinctResultsBasedOnStartPage()
            {
                var startOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1
                };

                var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions).ToList();

                var skipStartOptions = new ApiOptions
                {
                    PageSize = 5,
                    PageCount = 1,
                    StartPage = 2
                };

                var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions).ToList();

                Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
                Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
                Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
                Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
                Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
            }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:25,代碼來源:ObservableIssueCommentsClientTests.cs

示例14: FindAllAsync

        /// <summary>
        /// Gets a paginated list of APObjects matching the given search criteria.
        /// </summary>
        /// <param name="type">The object type.</param>
        /// <param name="query">The search query for objects to be found.</param>
        /// <param name="fields">The object fields to be returned for the matching list of objects.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The object field on which the results should be sorted.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Paginated list of APObject objects matching the given search criteria.</returns>
        public async static Task<PagedList<APObject>> FindAllAsync(string type, IQuery query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            query = query ?? Query.None;
            var request = new FindAllObjectsRequest()
            {
                Type = type,
                Query = query.AsString().Escape(),
                PageNumber = pageNumber,
                PageSize = pageSize,
                OrderBy = orderBy,
                SortOrder = sortOrder
            };
            if( fields != null )
                request.Fields.AddRange(fields);
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();
            if (response.Status.IsSuccessful == false)
                throw response.Status.ToFault();
            var objects = new PagedList<APObject>()
            {
                PageNumber = response.PagingInfo.PageNumber,
                PageSize = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage = async skip => await FindAllAsync(type, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };
            objects.AddRange(response.Objects);
            return objects;

        }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:41,代碼來源:APObjects.cs

示例15: GetAllStargazersWithTimestamps

        /// <summary>
        /// Retrieves all of the stargazers for the passed repository with star creation timestamps.
        /// </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>
        /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
        /// <returns>A <see cref="IObservable{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
        public IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string name, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(options, "options");

            return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps, options);
        }
開發者ID:jrusbatch,項目名稱:octokit.net,代碼行數:16,代碼來源:ObservableStarredClient.cs


注:本文中的ApiOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。