mirror of
https://github.com/ckaczor/Common.git
synced 2026-02-16 10:58:34 -05:00
Add support for updates from GitHub
This commit is contained in:
177
Update/GitHubRelease.cs
Normal file
177
Update/GitHubRelease.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Common.Update
|
||||
{
|
||||
public partial class GitHubRelease
|
||||
{
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonProperty("assets_url")]
|
||||
public string AssetsUrl { get; set; }
|
||||
|
||||
[JsonProperty("upload_url")]
|
||||
public string UploadUrl { get; set; }
|
||||
|
||||
[JsonProperty("html_url")]
|
||||
public string HtmlUrl { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonProperty("tag_name")]
|
||||
public string TagName { get; set; }
|
||||
|
||||
[JsonProperty("target_commitish")]
|
||||
public string TargetCommitish { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("draft")]
|
||||
public bool Draft { get; set; }
|
||||
|
||||
[JsonProperty("author")]
|
||||
public Uploader Author { get; set; }
|
||||
|
||||
[JsonProperty("prerelease")]
|
||||
public bool Prerelease { get; set; }
|
||||
|
||||
[JsonProperty("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("published_at")]
|
||||
public DateTimeOffset PublishedAt { get; set; }
|
||||
|
||||
[JsonProperty("assets")]
|
||||
public List<Asset> Assets { get; set; }
|
||||
|
||||
[JsonProperty("tarball_url")]
|
||||
public string TarballUrl { get; set; }
|
||||
|
||||
[JsonProperty("zipball_url")]
|
||||
public string ZipballUrl { get; set; }
|
||||
|
||||
[JsonProperty("body")]
|
||||
public string Body { get; set; }
|
||||
}
|
||||
|
||||
public class Asset
|
||||
{
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("uploader")]
|
||||
public Uploader Uploader { get; set; }
|
||||
|
||||
[JsonProperty("content_type")]
|
||||
public string ContentType { get; set; }
|
||||
|
||||
[JsonProperty("state")]
|
||||
public string State { get; set; }
|
||||
|
||||
[JsonProperty("size")]
|
||||
public long Size { get; set; }
|
||||
|
||||
[JsonProperty("download_count")]
|
||||
public long DownloadCount { get; set; }
|
||||
|
||||
[JsonProperty("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("updated_at")]
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
[JsonProperty("browser_download_url")]
|
||||
public string BrowserDownloadUrl { get; set; }
|
||||
}
|
||||
|
||||
public class Uploader
|
||||
{
|
||||
[JsonProperty("login")]
|
||||
public string Login { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonProperty("avatar_url")]
|
||||
public string AvatarUrl { get; set; }
|
||||
|
||||
[JsonProperty("gravatar_id")]
|
||||
public string GravatarId { get; set; }
|
||||
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonProperty("html_url")]
|
||||
public string HtmlUrl { get; set; }
|
||||
|
||||
[JsonProperty("followers_url")]
|
||||
public string FollowersUrl { get; set; }
|
||||
|
||||
[JsonProperty("following_url")]
|
||||
public string FollowingUrl { get; set; }
|
||||
|
||||
[JsonProperty("gists_url")]
|
||||
public string GistsUrl { get; set; }
|
||||
|
||||
[JsonProperty("starred_url")]
|
||||
public string StarredUrl { get; set; }
|
||||
|
||||
[JsonProperty("subscriptions_url")]
|
||||
public string SubscriptionsUrl { get; set; }
|
||||
|
||||
[JsonProperty("organizations_url")]
|
||||
public string OrganizationsUrl { get; set; }
|
||||
|
||||
[JsonProperty("repos_url")]
|
||||
public string ReposUrl { get; set; }
|
||||
|
||||
[JsonProperty("events_url")]
|
||||
public string EventsUrl { get; set; }
|
||||
|
||||
[JsonProperty("received_events_url")]
|
||||
public string ReceivedEventsUrl { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("site_admin")]
|
||||
public bool SiteAdmin { get; set; }
|
||||
}
|
||||
|
||||
public partial class GitHubRelease
|
||||
{
|
||||
public static GitHubRelease FromJson(string json) => JsonConvert.DeserializeObject<GitHubRelease>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
public static class Serialize
|
||||
{
|
||||
public static string ToJson(this GitHubRelease self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
|
||||
internal class Converter
|
||||
{
|
||||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
Converters = {
|
||||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user