Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
77 lines (73 loc) · 2.58 KB
/
Copy pathProgram.cs
File metadata and controls
77 lines (73 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Octokit.GraphQL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace NamedModelGitHubGraphQL
{
class Program
{
static void Main(string[] args)
{
AsyncMethod().Wait();
}
private static async Task AsyncMethod()
{
string token;
Connection connection;
token = System.Environment.GetEnvironmentVariable("GitHubTokenEX");
var productInformation = new ProductHeaderValue("octokit");
try { connection = new Connection(productInformation, token); }
catch (Exception ex)
{
Console.WriteLine("Connection error: " + ex.Message);
return;
}
// Repository.Issues is an IssueConnection
Octokit.GraphQL.Core.IQueryableValue<RepositoryModel> query = new Query()
.Repository("octokit.graphql.net", "octokit")
.Select(r => new RepositoryModel
{
Name = r.Name,
Description = r.Description,
TotalCount = r.Issues(100, null, null, null, null, null, null).TotalCount,
Issues = r.Issues(100, null, null, null, null, null, null)
.Nodes.Select(i => new IssueModel
{
Number = i.Number,
Title = i.Title,
}).ToList(),
});
try
{
RepositoryModel result = await connection.Run(query);
if (result != null)
{
Console.WriteLine($"{result.Name} ({result.Description}) has {result.TotalCount} issues");
foreach (IssueModel i in result.Issues)
Console.WriteLine($"{i.Number} {i.Title}");
}
else
Console.WriteLine("Null result");
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
if (ex.InnerException != null)
Console.WriteLine("InnerException: {0}", ex.InnerException.Message);
}
}
}
class RepositoryModel
{
public string Name { get; set; }
public string Description { get; set; }
public List<IssueModel> Issues { get; set; }
public int TotalCount;
}
class IssueModel
{
public int Number { get; set; }
public string Title { get; set; }
}
}