mirror of
https://github.com/ckaczor/Common.git
synced 2026-01-22 01:25:45 -05:00
Add update checking
This commit is contained in:
48
Update/VersionInfo.cs
Normal file
48
Update/VersionInfo.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Common.Debug;
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Common.Update
|
||||
{
|
||||
public class VersionInfo
|
||||
{
|
||||
public Version Version { get; set; }
|
||||
public string InstallFile { get; set; }
|
||||
public DateTime InstallCreated { get; set; }
|
||||
|
||||
public static VersionInfo Load(string server, string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
var document = XDocument.Load(server + file);
|
||||
|
||||
var versionInformationElement = document.Element("versionInformation");
|
||||
|
||||
if (versionInformationElement == null)
|
||||
return null;
|
||||
|
||||
var versionElement = versionInformationElement.Element("version");
|
||||
var installFileElement = versionInformationElement.Element("installFile");
|
||||
var installCreatedElement = versionInformationElement.Element("installCreated");
|
||||
|
||||
if (versionElement == null || installFileElement == null || installCreatedElement == null)
|
||||
return null;
|
||||
|
||||
var versionInfo = new VersionInfo
|
||||
{
|
||||
Version = Version.Parse(versionElement.Value),
|
||||
InstallFile = installFileElement.Value,
|
||||
InstallCreated = DateTime.Parse(installCreatedElement.Value)
|
||||
};
|
||||
|
||||
return versionInfo;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Tracer.WriteException(exception);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user