-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Flier
committed
Jul 26, 2018
1 parent
db849dc
commit cca50be
Showing
6 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Reflection; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace ConvertZZ.Moudle | ||
{ | ||
public class UpdateChecker | ||
{ | ||
public static VersionReport ChecktVersion() | ||
{ | ||
try | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
var response = client.GetAsync("https://raw.githubusercontent.com/flier268/ConvertZZ/master/ConvertZZ/Properties/AssemblyInfo.cs").Result; | ||
|
||
if (response.IsSuccessStatusCode) | ||
{ | ||
var responseContent = response.Content; | ||
string responseString = responseContent.ReadAsStringAsync().Result; | ||
string pattern = @"^\[assembly: AssemblyVersion\(""(.*?)""\)\]"; | ||
var m = Regex.Match(responseString, pattern,RegexOptions.Multiline); | ||
if (m.Success) | ||
{ | ||
Version ver = new Version(m.Groups[1].ToString().ToString()); | ||
Version version = Assembly.GetEntryAssembly().GetName().Version; | ||
int tm = version.CompareTo(ver); | ||
VersionReport versionReport = new VersionReport(); | ||
return new VersionReport() { Current = version, Newst = ver, HaveNew = tm < 0 }; | ||
} | ||
} | ||
} | ||
} | ||
catch { } | ||
return null; | ||
} | ||
public class VersionReport | ||
{ | ||
public Version Current { get; set; } | ||
public Version Newst { get; set; } | ||
public bool HaveNew { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters