• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ApiConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ApiConnection的典型用法代码示例。如果您正苦于以下问题:C# ApiConnection类的具体用法?C# ApiConnection怎么用?C# ApiConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ApiConnection类属于命名空间,在下文中一共展示了ApiConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EnsuresArgumentNotNull

 public async Task EnsuresArgumentNotNull()
 {
     var getUri = new Uri("anything", UriKind.Relative);
     var client = new ApiConnection(Substitute.For<IConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get<object>(null));
     await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get<object>(getUri, new Dictionary<string, string>(), null));
 }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:7,代码来源:ApiConnectionTests.cs


示例2: page

        public List<Developer> page(int page = 1, int size = 40)
        {
            var credentials = new Octokit.Credentials(ConfigurationManager.AppSettings["user_git"], ConfigurationManager.AppSettings["pass_git"]);
            Octokit.Connection connection = new Connection(new ProductHeaderValue("DevStore"));
            Octokit.ApiConnection apiConn = new ApiConnection(connection);
            Octokit.SearchUsersRequest search = new SearchUsersRequest("a");
            search.AccountType = AccountSearchType.User;
            search.PerPage = size;
            search.Page = page;
            Octokit.UsersClient userCliente = new UsersClient(apiConn);
            Octokit.SearchClient searchUserService = new SearchClient(apiConn);
            SearchUsersResult usersResult = searchUserService.SearchUsers(search).Result;
            Octokit.GitHubClient gitClient = new GitHubClient(connection);
            Octokit.UsersClient userClient = new UsersClient(apiConn);
            List<Developer> developers = (from userGit in usersResult.Items
                                          select new Developer
                                          {
                                              User = userGit.Login,
                                              UrlAvatar = userGit.AvatarUrl.ToString(),
                                              TotalRepo = userGit.PublicRepos,
                                              TotalFollowers = userGit.Followers,
                                              Price = ((userGit.PublicRepos * pesoTotalRepository) + (userGit.Followers * pesoTotalFollowers)) / (pesoTotalRepository + pesoTotalFollowers)
                                          }).ToList();

            return developers;
        }
开发者ID:milkidis,项目名称:devstore,代码行数:26,代码来源:DeveloperService.cs


示例3: PlatronClient

        public PlatronClient(IConnection connection)
        {
            Ensure.ArgumentNotNull(connection, "connection");
            _connection = new ApiConnection(connection);

            ResultUrl = new ResultUrlClient(_connection);
        }
开发者ID:alex-erygin,项目名称:Platron.Client,代码行数:7,代码来源:PlatronClient.cs


示例4: ResultUrlClient

        public ResultUrlClient(ApiConnection connection)
        {
            Ensure.ArgumentNotNull(connection, nameof(connection));
            Ensure.ArgumentNotNull(connection.Callback, nameof(connection.Callback));

            _callback = connection.Callback;
        }
开发者ID:alex-erygin,项目名称:Platron.Client,代码行数:7,代码来源:ResultUrlClient.cs


示例5: GitHubClient

        /// <summary>
        /// Create a new instance of the GitHub API v3 client using the specified connection.
        /// </summary>
        /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param>
        public GitHubClient(IConnection connection)
        {
            Ensure.ArgumentNotNull(connection, "connection");

            Connection = connection;
            var apiConnection = new ApiConnection(connection);
            Activity = new ActivitiesClient(apiConnection);
            Authorization = new AuthorizationsClient(apiConnection);
            Deployment = new DeploymentsClient(apiConnection);
            Enterprise = new EnterpriseClient(apiConnection);
            Gist = new GistsClient(apiConnection);
            Git = new GitDatabaseClient(apiConnection);
            Issue = new IssuesClient(apiConnection);
            Migration = new MigrationClient(apiConnection);
            Miscellaneous = new MiscellaneousClient(connection);
            Notification = new NotificationsClient(apiConnection);
            Oauth = new OauthClient(connection);
            Organization = new OrganizationsClient(apiConnection);
            PullRequest = new PullRequestsClient(apiConnection);
            Repository = new RepositoriesClient(apiConnection);
            Search = new SearchClient(apiConnection);
            SshKey = new SshKeysClient(apiConnection);
            User = new UsersClient(apiConnection);
            Reaction = new ReactionsClient(apiConnection);
        }
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:29,代码来源:GitHubClient.cs


示例6: Can_hit_endpoint_if_I_pass_credentials_into_api

		public async Task Can_hit_endpoint_if_I_pass_credentials_into_api()
		{
			IApi api = new ApiConnection();
			var request = api.Create<Status>();
			var status = await request.Please();

			Assert.That(status, Is.Not.Null);
			Assert.That(status.ServerTime.Day, Is.EqualTo(DateTime.Now.Day));
		}
开发者ID:danhaller,项目名称:SevenDigital.Api.Schema,代码行数:9,代码来源:ApiSetupCredentialPassingTests.cs


示例7: Initialize

        /// <summary>
        /// Initialize the API using the config.json file.
        /// </summary>
        public virtual void Initialize(int userId, string token)
        {
            _connection = new ApiConnection(userId, token);
            _marketHoursDatabase = MarketHoursDatabase.FromDataFolder();

            //Allow proper decoding of orders from the API.
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Converters = { new OrderJsonConverter() }
            };
        }
开发者ID:aajtodd,项目名称:Lean,代码行数:14,代码来源:Api.cs


示例8: GetMe

        public async static Task<UserData> GetMe(ApiConnection connection)
        {
            var request = new HttpRequestMessage(HttpMethod.Get, connection.Endpoints.Me);
            request.Headers.Add(connection.Endpoints.Headers.ApiKey, connection.Token);
            request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(content_type));

            var client = new HttpClient();
            var response = await client.SendAsync(request);
            var content = await response.Content.ReadAsStringAsync();

            return new UserData(content);
        }
开发者ID:kenlefeb,项目名称:AgileZen,代码行数:12,代码来源:Api.cs


示例9: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            if (parameters.Length < 5)
            {
                await response.Send($"I don't understand '{string.Join(" ", parameters.Select(x => "[" + x + "]"))}'.");
                return;
            }
            var repo = parameters[1];
            var issueNumberString = parameters[2];
            var from = parameters[3];
            var to = parameters[4];

            string accessToken;

            if (!TryGetCredential("github-accesstoken", out accessToken))
            {
                await response.Send("I couldnt find a github access token in your credentials. If you add one I will be able to create the pull request on your behalf. Does it sound good? Here are the instructions https://github.com/Particular/Housekeeping/wiki/Generate-GitHub-access-token-for-PBot");

                return;
            }

            var client = GitHubClientBuilder.Build(accessToken);

            var apiConnection = new ApiConnection(client.Connection);

            int issueNumber;
            if (!int.TryParse(issueNumberString, out issueNumber))
            {
                await response.Send("Issue number should be a valid number dude!");
                return;
            }
            try
            {

                var result = await apiConnection.Post<PullRequest>(ApiUrls.PullRequests("Particular", repo), new ConvertedPullRequest
                {
                    Issue = issueNumber.ToString(),
                    Head = from,
                    Base = to
                }, null, "application/json");
                await response.Send($"Issue {issueNumber} has been converted into a pull request {result.HtmlUrl}.");
            }
            catch (NotFoundException)
            {
                response.Send("Sorry, GitHub could not find the issue or repository you are talking about.").ConfigureAwait(false).GetAwaiter().GetResult();
            }
            catch (ApiValidationException ex)
            {
                const string errorMessage = "Sorry, your request was rejected by GitHub as invalid.";
                response.Send(string.Join(Environment.NewLine, errorMessage, ex.GetExtendedErrorMessage())).ConfigureAwait(false).GetAwaiter().GetResult();
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:52,代码来源:ConvertIssueToPullRequest.cs


示例10: MakesHtmlRequest

            public async Task MakesHtmlRequest()
            {
                var getUri = new Uri("anything", UriKind.Relative);
                IApiResponse<string> response = new ApiResponse<string>(new Response(), "<html />");
                var connection = Substitute.For<IConnection>();
                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.GetHtml(getUri);

                Assert.Equal("<html />", data);
                connection.Received().GetHtml(getUri);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:13,代码来源:ApiConnectionTests.cs


示例11: MakesGetRequestForItem

            public async Task MakesGetRequestForItem()
            {
                var getUri = new Uri("anything", UriKind.Relative);
                IApiResponse<object> response = new ApiResponse<object>(new Response());
                var connection = Substitute.For<IConnection>();
                connection.Get<object>(Args.Uri, null, null).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Get<object>(getUri);

                Assert.Same(response.Body, data);
                connection.Received().GetResponse<object>(getUri);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:13,代码来源:ApiConnectionTests.cs


示例12: MakesGetRequestForItemWithAcceptsOverride

            public async Task MakesGetRequestForItemWithAcceptsOverride()
            {
                var getUri = new Uri("anything", UriKind.Relative);
                var accepts = "custom/accepts";
                IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<object>(Args.Uri, null, Args.String).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.Get<object>(getUri, null, accepts);

                Assert.Same(response.BodyAsObject, data);
                connection.Received().GetAsync<object>(getUri, null, accepts);
            }
开发者ID:rajwilkhu,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs


示例13: GitHubClient

        /// <summary>
        /// Create a new instance of the GitHub API v3 client using the specified connection.
        /// </summary>
        /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests.</param>
        public GitHubClient(IConnection connection)
        {
            Ensure.ArgumentNotNull(connection, "connection");

            Connection = connection;
            var apiConnection = new ApiConnection(connection);
            Authorization = new AuthorizationsClient(apiConnection);
            Issue = new IssuesClient(apiConnection);
            Miscellaneous = new MiscellaneousClient(connection);
            Notification = new NotificationsClient(apiConnection);
            Organization = new OrganizationsClient(apiConnection);
            Repository = new RepositoriesClient(apiConnection);
            Release = new ReleasesClient(apiConnection);
            User = new UsersClient(apiConnection);
            SshKey = new SshKeysClient(apiConnection);
        }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:20,代码来源:GitHubClient.cs


示例14: MakesGetRequestForAllItems

            public async Task MakesGetRequestForAllItems()
            {
                var getAllUri = new Uri("anything", UriKind.Relative);
                var links = new Dictionary<string, Uri>();
                var scopes = new List<string>();
                IResponse<List<object>> response = new ApiResponse<List<object>>
                {
                    ApiInfo = new ApiInfo(links, scopes, scopes, "etag", new RateLimit(new Dictionary<string, string>())),
                    BodyAsObject = new List<object> {new object(), new object()}
                };
                var connection = Substitute.For<IConnection>();
                connection.GetAsync<List<object>>(Args.Uri, null, null).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                var data = await apiConnection.GetAll<object>(getAllUri);

                Assert.Equal(2, data.Count);
                connection.Received().GetAsync<List<object>>(getAllUri, null, null);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:19,代码来源:ApiConnectionTests.cs


示例15: GitHubClient

        /// <summary>
        /// Create a new instance of the GitHub API v3 client using the specified connection.
        /// </summary>
        /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param>
        public GitHubClient(IConnection connection)
        {
            Ensure.ArgumentNotNull(connection, "connection");

            Connection = connection;
            var apiConnection = new ApiConnection(connection);
            Authorization = new AuthorizationsClient(apiConnection);
            Activity = new ActivitiesClient(apiConnection);
            Blob = new BlobsClient(apiConnection);
            Issue = new IssuesClient(apiConnection);
            Miscellaneous = new MiscellaneousClient(connection);
            Notification = new NotificationsClient(apiConnection);
            Organization = new OrganizationsClient(apiConnection);
            Repository = new RepositoriesClient(apiConnection);
            Gist = new GistsClient(apiConnection);
            Release = new ReleasesClient(apiConnection);
            User = new UsersClient(apiConnection);
            SshKey = new SshKeysClient(apiConnection);
            GitDatabase = new GitDatabaseClient(apiConnection);
            Tree = new TreesClient(apiConnection);
            Search = new SearchClient(apiConnection);
        }
开发者ID:rgmills,项目名称:octokit.net,代码行数:26,代码来源:GitHubClient.cs


示例16: IndexManagementClient

 public IndexManagementClient(ApiConnection connection)
 {
     _connection = connection;
 }
开发者ID:harutama,项目名称:RedDog.Search,代码行数:4,代码来源:IndexManagementClient.cs


示例17: UsersClient

 /// <summary>
 /// Initializes a new instance of the <see cref="UsersClient"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public UsersClient(ApiConnection connection)
     : base(connection)
 {
 }
开发者ID:damienspivak,项目名称:auth0.net,代码行数:8,代码来源:UsersClient.cs


示例18: MakesGetRequest

            public async Task MakesGetRequest()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.OK;
                IApiResponse<object> response = new ApiResponse<object>(new Response(statusCode, null, new Dictionary<string, string>(), "application/json"), new object());
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl,Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await apiConnection.GetQueuedOperation<object>(queuedOperationUrl,CancellationToken.None);

                connection.Received().GetResponse<object>(queuedOperationUrl, Args.CancellationToken);
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:14,代码来源:ApiConnectionTests.cs


示例19: RulesClient

 /// <summary>
 /// Initializes a new instance of the <see cref="RulesClient"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public RulesClient(ApiConnection connection)
     : base(connection)
 {
 }
开发者ID:jerriep,项目名称:auth0.net,代码行数:8,代码来源:RulesClient.cs


示例20: WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown

            public async Task WhenGetReturnsNotOkOrAcceptedApiExceptionIsThrown()
            {
                var queuedOperationUrl = new Uri("anything", UriKind.Relative);

                const HttpStatusCode statusCode = HttpStatusCode.PartialContent;
                IApiResponse<object> response = new ApiResponse<object>(new Response(statusCode, null, new Dictionary<string, string>(), "application/json"), new object());
                var connection = Substitute.For<IConnection>();
                connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
                var apiConnection = new ApiConnection(connection);

                await Assert.ThrowsAsync<ApiException>(() => apiConnection.GetQueuedOperation<object>(queuedOperationUrl, Args.CancellationToken));
            }
开发者ID:alexgyori,项目名称:octokit.net,代码行数:12,代码来源:ApiConnectionTests.cs



注:本文中的ApiConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ApiController类代码示例发布时间:2022-05-24
下一篇:
C# ApiClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap