当前位置: 首页>>代码示例>>C#>>正文


C# GitHubClient类代码示例

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


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

示例1: CreatesANewPrivateRepository

            public async Task CreatesANewPrivateRepository()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = Helper.Credentials
                };
                var repoName = Helper.MakeNameWithTimestamp("private-repo");

                var createdRepository = await github.Repository.Create(new NewRepository
                {
                    Name = repoName,
                    Private = true
                });

                try
                {
                    Assert.True(createdRepository.Private);
                    var repository = await github.Repository.Get(github.Credentials.Login, repoName);
                    Assert.True(repository.Private);
                }
                finally
                {
                    Helper.DeleteRepo(createdRepository);
                }
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:25,代码来源:RepositoriesClientTests.cs

示例2: Main

 public void Main(string[] args)
 {
     var client = new GitHubClient(new ProductHeaderValue("coreclr"));
     var result = client.User.Get("naveensrinivasan").Result;
     Console.WriteLine(result.Name);
     Console.WriteLine(result.HtmlUrl);
 }
开发者ID:naveensrinivasan,项目名称:OctokitCoreClrSample,代码行数:7,代码来源:Program.cs

示例3: CreatesARepositoryWithoutDownloads

            public async Task CreatesARepositoryWithoutDownloads()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = Helper.Credentials
                };
                var repoName = Helper.MakeNameWithTimestamp("repo-without-downloads");

                var createdRepository = await github.Repository.Create(new NewRepository
                {
                    Name = repoName,
                    HasDownloads = false
                });

                try
                {
                    Assert.False(createdRepository.HasDownloads);
                    var repository = await github.Repository.Get(github.Credentials.Login, repoName);
                    Assert.False(repository.HasDownloads);
                }
                finally
                {
                    Helper.DeleteRepo(createdRepository);
                }
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:25,代码来源:RepositoriesClientTests.cs

示例4: CreateIssueTracker

        public IIssueTracker CreateIssueTracker(Context context, IRepository repository)
        {
            switch (context.GetIssueTracker())
            {
                case IssueTracker.BitBucket:
                    break;

                case IssueTracker.GitHub:
                    return new GitHubIssueTracker(repository, () =>
                    {
                        var gitHubClient = new GitHubClient(new ProductHeaderValue("GitReleaseNotes"));
                        if (context.IssueTracker.Token != null)
                        {
                            gitHubClient.Credentials = new Octokit.Credentials(context.IssueTracker.Token);
                        }

                        return gitHubClient;
                    }, context);

                case IssueTracker.Jira:
                    return new JiraIssueTracker(new JiraApi(), context);

                case IssueTracker.YouTrack:
                    return new YouTrackIssueTracker(new YouTrackApi(), context);
            }

            return null;
        }
开发者ID:bendetat,项目名称:GitReleaseNotes,代码行数:28,代码来源:IssueTrackerFactory.cs

示例5: 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

示例6: CreatesANewPublicRepository

            public async Task CreatesANewPublicRepository()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = Helper.Credentials
                };
                var repoName = Helper.MakeNameWithTimestamp("public-repo");

                var createdRepository = await github.Repository.Create(new NewRepository { Name = repoName });
                
                try
                {
                    var cloneUrl = string.Format("https://github.com/{0}/{1}.git", github.Credentials.Login, repoName);
                    Assert.Equal(repoName, createdRepository.Name);
                    Assert.False(createdRepository.Private);
                    Assert.Equal(cloneUrl, createdRepository.CloneUrl);
                    var repository = await github.Repository.Get(github.Credentials.Login, repoName);
                    Assert.Equal(repoName, repository.Name);
                    Assert.Null(repository.Description);
                    Assert.False(repository.Private);
                    Assert.True(repository.HasDownloads);
                    Assert.True(repository.HasIssues);
                    Assert.True(repository.HasWiki);
                    Assert.Null(repository.Homepage);
                }
                finally
                {
                    Helper.DeleteRepo(createdRepository);
                }
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:30,代码来源:RepositoriesClientTests.cs

示例7: GetsRootContents

            public async Task GetsRootContents()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = Helper.Credentials
                };

                var contents = await github.Repository.Contents.GetForPath("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs");
            }
开发者ID:Feng2012,项目名称:octokit.net,代码行数:9,代码来源:RepositoryContentsClientTests.cs

示例8: DeleteRepo

 public static void DeleteRepo(string owner, string name)
 {
     var api = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Credentials };
     try
     {
         api.Repository.Delete(owner, name).Wait(TimeSpan.FromSeconds(15));
     }
     catch { }
 }
开发者ID:ninadamondikar,项目名称:octokit.net,代码行数:9,代码来源:Helper.cs

示例9: Overseer

 public Overseer(CancellationToken token, BuildServerClient buildServerClient, GitHubClient gitHubClient, string user, string repo, string branch)
 {
     m_token = token;
     m_buildServerClient = buildServerClient;
     m_gitHubClient = gitHubClient;
     m_user = user;
     m_repo = repo;
     m_branch = branch;
 }
开发者ID:LogosBible,项目名称:Leeroy,代码行数:9,代码来源:Overseer.cs

示例10: CanCreateBasicAuthClient

            public void CanCreateBasicAuthClient()
            {
                var client = new GitHubClient(new ProductHeaderValue("OctokitTests", "1.0"))
                {
                    Credentials = new Credentials("tclem", "pwd")
                };

                Assert.Equal(AuthenticationType.Basic, client.Credentials.AuthenticationType);
            }
开发者ID:naveensrinivasan,项目名称:octokit.net,代码行数:9,代码来源:GitHubClientTests.cs

示例11: CanCreateOauthClient

            public void CanCreateOauthClient()
            {
                var client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = new Credentials("token")
                };

                Assert.Equal(AuthenticationType.Oauth, client.Credentials.AuthenticationType);
            }
开发者ID:naveensrinivasan,项目名称:octokit.net,代码行数:9,代码来源:GitHubClientTests.cs

示例12: RequestsCorrectUrlWithRepositoryId

            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableIssuesLabelsClient(gitHubClient);

                client.GetAllForIssue(1, 42);

                connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, null);
            }
开发者ID:daveaglick,项目名称:octokit.net,代码行数:10,代码来源:ObservableIssuesLabelsClientTests.cs

示例13: ReturnsSpecifiedUserUsingAwaitableCredentialProvider

            public async Task ReturnsSpecifiedUserUsingAwaitableCredentialProvider()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"),
                    new ObservableCredentialProvider());

                // Get a user by username
                var user = await github.User.Get("tclem");

                Assert.Equal("GitHub", user.Company);
            }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:10,代码来源:UsersClientTests.cs

示例14: CanGetEmail

        public async Task CanGetEmail()
        {
            var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
            {
                Credentials = Helper.Credentials
            };

            var emails = await github.User.Email.GetAll();
            Assert.NotEmpty(emails);
        }
开发者ID:harunpehlivan,项目名称:octokit.net,代码行数:10,代码来源:UserEmailsClientTests.cs

示例15: CanRenderGitHubFlavoredMarkdown

 public async Task CanRenderGitHubFlavoredMarkdown()
 {
     var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
     {
         Credentials = Helper.Credentials
     };
 
     var result = await github.Miscellaneous.RenderRawMarkdown("This is a **test**");
     
     Assert.Equal("<p>This is a <strong>test</strong></p>", result);
 }
开发者ID:ninjanye,项目名称:octokit.net,代码行数:11,代码来源:MiscellaneousClientTests.cs


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