-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
77 lines (68 loc) · 2.38 KB
/
Program.cs
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 System;
using System.IO;
using Octokit;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using System.Net;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
namespace UmbraInjector
{
static class Program
{
public static bool updateAvailable;
public static string latestVersion;
public static bool devBuild;
public static bool upToDate = true;
public static bool rateLimited = false;
public const string
VERSION = "1.0.0";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(new MainForm());
}
public static async void CheckForUpdate()
{
var client = new GitHubClient(new ProductHeaderValue("UmbraUnlockUpdateCheck"));
try
{
var releases = await client.Repository.Release.GetAll("Acher0ns", "Umbra-Unlock-All").ConfigureAwait(false);
var latest = releases[0];
latestVersion = latest.TagName;
string[] versionSplit = VERSION.Split('.');
string[] latestVersionSplit = latestVersion.Split('.');
for (int i = 0; i < versionSplit.Length; i++)
{
int versionNumber = int.Parse(versionSplit[i]);
int latestVersionNumber = int.Parse(latestVersionSplit[i]);
if (versionNumber < latestVersionNumber)
{
upToDate = false;
devBuild = false;
updateAvailable = true;
break;
}
else if (versionNumber > latestVersionNumber)
{
upToDate = false;
devBuild = true;
updateAvailable = false;
break;
}
}
}
catch (RateLimitExceededException)
{
rateLimited = true;
upToDate = true;
}
}
}
}