| | 1 | | using System; |
| | 2 | | using Octokit; |
| | 3 | |
|
| | 4 | | namespace ApplicationCore |
| | 5 | | { |
| | 6 | | public class GitHubClientFactory : IGitHubClientFactory |
| | 7 | | { |
| | 8 | | private readonly GitHubConfig _config; |
| | 9 | |
|
| 5 | 10 | | public GitHubClientFactory(GitHubConfig config) |
| 5 | 11 | | { |
| 5 | 12 | | _config = config ?? throw new ArgumentNullException(nameof(config)); |
| 4 | 13 | | } |
| | 14 | |
|
| | 15 | | public IGitHubClient CreateClient() |
| 4 | 16 | | { |
| 4 | 17 | | var credentials = _config.Token.Length > 0 |
| 4 | 18 | | ? new Credentials(_config.Token) |
| 4 | 19 | | : Credentials.Anonymous; |
| | 20 | |
|
| 4 | 21 | | return new GitHubClient( |
| 4 | 22 | | new ProductHeaderValue("PostCommentToPullRequest"), |
| 4 | 23 | | new Octokit.Internal.InMemoryCredentialStore(credentials)); |
| 4 | 24 | | } |
| | 25 | | } |
| | 26 | | } |