Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Created July 21, 2020 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/945ed92d5f2feb7076c321d522a32fdd to your computer and use it in GitHub Desktop.
Save gistlyn/945ed92d5f2feb7076c321d522a32fdd to your computer and use it in GitHub Desktop.
text files
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack.Text" Version="5.*" />
</ItemGroup>
</Project>
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
public class GithubRepository
{
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public string Homepage { get; set; }
public string Language { get; set; }
public int Watchers { get; set; }
public int Forks { get; set; }
public override string ToString() => Name;
}
public static class Program
{
static void Main()
{
//https://githubengineering.com/crypto-removal-notice/
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var orgName = "ServiceStack";
var orgRepos = $"https://api.github.com/orgs/{orgName}/repos"
.GetJsonFromUrl(httpReq => httpReq.UserAgent = "ServiceStack Demo")
.FromJson<GithubRepository[]>()
.OrderByDescending(x => x.Watchers)
.Take(5)
.ToList();
"Top 5 {0} Github Repositories:".Print(orgName);
orgRepos.PrintDump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment