-
Notifications
You must be signed in to change notification settings - Fork 22
/
SoftwareUpdater.cs
54 lines (50 loc) · 1.46 KB
/
SoftwareUpdater.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Cracker
{
public class SoftwareUpdater : Updater
{
private Version m_Version;
private string m_Url;
public SoftwareUpdater()
: base("http://www.xiaonh.com/bitcoincracker/software.json")
{
m_Version = new Version();
m_Url = null;
}
public bool HasNew
{
get
{
AssemblyProductAttribute productAttr = (AssemblyProductAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute));
string product = productAttr.Product;
Version version = Assembly.GetExecutingAssembly().GetName().Version;
return m_Version > version;
}
}
public string Url { get { return m_Url; } }
public bool Update()
{
try
{
string json = ReadJson();
JObject obj = JsonConvert.DeserializeObject<JObject>(json);
m_Version = Version.Parse((string)obj["Version"]);
m_Url = (string)obj["Url"];
return true;
}
catch
{
return false;
}
}
}
}