-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParseClasses.cs
More file actions
93 lines (88 loc) · 2.93 KB
/
ParseClasses.cs
File metadata and controls
93 lines (88 loc) · 2.93 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
namespace PolyTechFramework
{
public class Author
{
public int id { get; set; }
public string login { get; set; }
public string full_name { get; set; }
public string email { get; set; }
public string avatar_url { get; set; }
public string language { get; set; }
public bool is_admin { get; set; }
public string last_login { get; set; } // DateTime
public string created { get; set; } // DateTime
public string username { get; set; }
}
public class Asset
{
public int id { get; set; }
public string name { get; set; }
public int size { get; set; }
public int download_count { get; set; }
public string created_at { get; set; } // DateTime
public string uuid { get; set; }
public string browser_download_url { get; set; }
}
public class Release
{
public int id { get; set; }
public string tag_name { get; set; }
public string target_commitish { get; set; }
public string name { get; set; }
public string body { get; set; }
public string url { get; set; }
public string html_url { get; set; }
public string tarball_url { get; set; }
public string zipball_url { get; set; }
public bool draft { get; set; }
public bool prerelease { get; set; }
public string created_at { get; set; } // DateTime
public string published_at { get; set; } // DateTime
public Author author { get; set; }
public List<Asset> assets { get; set; }
public System.Version GetVersion()
{
System.Version version;
string parsed = this.tag_name.ToLower().Replace("v", "");
int pos;
pos = parsed.IndexOf("-");
if (pos != -1) parsed = parsed.Substring(0, pos);
pos = parsed.IndexOf("+");;
if (pos != -1) parsed = parsed.Substring(0, pos);
try {
version = new System.Version(parsed);
}
catch (FormatException)
{
PolyTechMain.ptfInstance.ptfLogger.LogError("Invalid Version found while checking for mod updates, using fallback value 0.0.0");
version = new System.Version("0.0.0");
}
return version;
}
}
public class ModUpdate
{
public System.Version new_version {
get
{
return latest_release.GetVersion();
}
}
public System.Version old_version
{
get
{
return mod.Info.Metadata.Version;
}
}
public PolyTechMod mod;
public Release latest_release;
public ModUpdate(PolyTechMod mod, Release latest_release)
{
this.mod = mod;
this.latest_release = latest_release;
}
}
}