forked from unitycoder/UnityLauncherPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetUnityUpdates.cs
More file actions
70 lines (63 loc) · 2.47 KB
/
Copy pathGetUnityUpdates.cs
File metadata and controls
70 lines (63 loc) · 2.47 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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Threading.Tasks;
namespace UnityLauncherPro
{
public static class GetUnityUpdates
{
static bool isDownloadingUnityList = false;
static readonly string unityVersionsURL = @"http://symbolserver.unity3d.com/000Admin/history.txt";
public static async Task<string> Scan()
{
if (isDownloadingUnityList == true)
{
Console.WriteLine("We are already downloading ...");
return null;
}
isDownloadingUnityList = true;
//SetStatus("Downloading list of Unity versions ...");
string result = null;
// download list of Unity versions
using (WebClient webClient = new WebClient())
{
Task<string> downloadStringTask = webClient.DownloadStringTaskAsync(new Uri(unityVersionsURL));
try
{
result = await downloadStringTask;
}
catch (WebException)
{
Console.WriteLine("It's a web exception");
}
catch (Exception)
{
Console.WriteLine("It's not a web exception");
}
isDownloadingUnityList = false;
}
return result;
}
public static Updates[] Parse(string items)// object sender, DownloadStringCompletedEventArgs e)
{
isDownloadingUnityList = false;
//SetStatus("Downloading list of Unity versions ... done");
var receivedList = items.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
if (receivedList == null && receivedList.Length < 1) return null;
Array.Reverse(receivedList);
var updates = new List<Updates>();
// parse into data
for (int i = 0, len = receivedList.Length; i < len; i++)
{
var row = receivedList[i].Split(',');
var versionTemp = row[6].Trim('"');
var u = new Updates();
u.ReleaseDate = DateTime.ParseExact(row[3], "MM/dd/yyyy", CultureInfo.InvariantCulture); //DateTime ? lastUpdated = Tools.GetLastModifiedTime(csprojFile);
u.Version = versionTemp;
updates.Add(u);
}
return updates.ToArray();
}
}
}