forked from benrhughes/todotxt.net
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Updateversion code from MainWindow
- Loading branch information
Showing
3 changed files
with
61 additions
and
49 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,45 @@ | |||
using System; | |||
using System.Threading; | |||
using System.Xml; | |||
using ToDoLib; | |||
using System.Windows; | |||
|
|||
namespace Client | |||
{ | |||
class CheckUpdate | |||
{ | |||
public const string updateXMLUrl = @"https://raw.github.com/benrhughes/todotxt.net/master/Updates.xml"; | |||
public const string updateClientUrl = @"https://github.com/benrhughes/todotxt.net/downloads"; | |||
|
|||
public delegate void CheckUpdateVershion(string version); | |||
public event CheckUpdateVershion OnCheckedUpdateVershion; | |||
|
|||
private XmlDocument xDoc; | |||
|
|||
public CheckUpdate() | |||
{ | |||
xDoc = new XmlDocument(); | |||
} | |||
|
|||
public void Check() | |||
{ | |||
ThreadPool.QueueUserWorkItem(x => CheckForUpdates()); | |||
} | |||
|
|||
private void CheckForUpdates() | |||
{ | |||
try | |||
{ | |||
xDoc.Load(new XmlTextReader(updateXMLUrl)); | |||
|
|||
var version = xDoc.SelectSingleNode("//version").InnerText; | |||
var changelog = xDoc.SelectSingleNode("//changelog").InnerText; | |||
OnCheckedUpdateVershion(version); | |||
} | |||
catch (Exception ex) | |||
{ | |||
Log.Error("Error checking for updates", ex); | |||
} | |||
} | |||
} | |||
} |
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