private static UpdateResult GetUpdateResult()
{
var updateResult = new UpdateResult();
XmlTextReader reader = null;
try
{
string url = BrowserHelper.Host + "/updatecheck.php?platform=pc&version=" + Application.ProductVersion;
#if DEBUG
//uncomment this if you want to check live site
//url = "http://test.highlighthunter.com/updatecheck.php?platform=pc&version=1.2.0.0";
#endif
// Load the reader with the data file and ignore all white space nodes.
reader = new XmlTextReader(url)
{
WhitespaceHandling = WhitespaceHandling.None
};
//logger.Info("Contents of update check: " + reader.ReadContentAsString());
reader.ReadStartElement("updateResults");
updateResult.IsUpdateAvailable = Boolean.Parse(reader.ReadElementString("isUpdateAvailable"));
updateResult.LatestVersion = reader.ReadElementString("latestVersion");
updateResult.WhatsNew = reader.ReadElementString("whatsNew");
updateResult.DownloadPage = reader.ReadElementString("downloadPage");
/*
// Parse the file and display each of the nodes.
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Console.WriteLine("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.WriteLine(reader.Value);
break;
case XmlNodeType.CDATA:
Console.WriteLine("<![CDATA[{0}]]>", reader.Value);
break;
case XmlNodeType.ProcessingInstruction:
Console.WriteLine("<?{0} {1}?>", reader.Name, reader.Value);
break;
case XmlNodeType.Comment:
Console.WriteLine("<!--{0}-->", reader.Value);
break;
case XmlNodeType.XmlDeclaration:
Console.WriteLine("<?xml version='1.0'?>");
break;
case XmlNodeType.Document:
break;
case XmlNodeType.DocumentType:
Console.WriteLine("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);
break;
case XmlNodeType.EntityReference:
Console.WriteLine(reader.Name);
break;
case XmlNodeType.EndElement:
Console.WriteLine("</{0}>", reader.Name);
break;
}
}
*/
}
catch (Exception ex)
{
Logger.Error("Exception checking for update: " + ex.ToString());
}
finally
{
if (reader != null)
reader.Close();
}
return updateResult;
}