mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-21 04:43:55 +12:00
Partial update to update mechanism.
This commit is contained in:
parent
2155f81d99
commit
b75214d5e4
|
@ -87,15 +87,6 @@ namespace OnTopReplica.Update {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Serialize(UpdateInformation information) {
|
|
||||||
var serializer = new XmlSerializer(typeof(UpdateInformation));
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
using(var writer = new StringWriter(sb)){
|
|
||||||
serializer.Serialize(writer, information);
|
|
||||||
}
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Cache;
|
using System.Net.Cache;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Xml.Linq;
|
||||||
using WindowsFormsAero.TaskDialog;
|
using WindowsFormsAero.TaskDialog;
|
||||||
|
|
||||||
namespace OnTopReplica.Update {
|
namespace OnTopReplica.Update {
|
||||||
|
@ -31,7 +34,7 @@ namespace OnTopReplica.Update {
|
||||||
|
|
||||||
#region Checking
|
#region Checking
|
||||||
|
|
||||||
const string UpdateManifestUrl = "http://www.klopfenstein.net/public/Uploads/ontopreplica/update.xml";
|
const string UpdateFeedUrl = "https://ontopreplica.codeplex.com/project/feeds/rss?ProjectRSSFeed=codeplex%3a%2f%2frelease%2fontopreplica";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the latest update information available.
|
/// Gets the latest update information available.
|
||||||
|
@ -50,7 +53,7 @@ namespace OnTopReplica.Update {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Build web request
|
//Build web request
|
||||||
_checkRequest = (HttpWebRequest)HttpWebRequest.Create(UpdateManifestUrl);
|
_checkRequest = (HttpWebRequest)HttpWebRequest.Create(UpdateFeedUrl);
|
||||||
_checkRequest.AllowAutoRedirect = true;
|
_checkRequest.AllowAutoRedirect = true;
|
||||||
_checkRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
|
_checkRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
|
||||||
_checkRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
|
_checkRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
|
||||||
|
@ -67,7 +70,7 @@ namespace OnTopReplica.Update {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = _checkRequest.EndGetResponse(result);
|
var response = _checkRequest.EndGetResponse(result);
|
||||||
LastInformation = UpdateInformation.Deserialize(response.GetResponseStream());
|
LastInformation = ParseUpdateCheckResponse(response.GetResponseStream());
|
||||||
|
|
||||||
OnUpdateCheckSuccess(LastInformation);
|
OnUpdateCheckSuccess(LastInformation);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +81,22 @@ namespace OnTopReplica.Update {
|
||||||
_checkRequest = null;
|
_checkRequest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Regex _versionExtractor = new Regex(@"^Released: Release (?<version>([0-9]\.){0,3}[0-9]?)", RegexOptions.Compiled | RegexOptions.Singleline);
|
||||||
|
|
||||||
|
private UpdateInformation ParseUpdateCheckResponse(Stream stream) {
|
||||||
|
var xdoc = XDocument.Load(stream);
|
||||||
|
|
||||||
|
var releases = from item in xdoc.Descendants("item")
|
||||||
|
let title = item.Element("title").Value
|
||||||
|
let match = _versionExtractor.Match(title)
|
||||||
|
where match.Success
|
||||||
|
let versionNumber = match.Groups["version"].Value
|
||||||
|
orderby versionNumber descending
|
||||||
|
select new { versionNumber, item.Element("link").Value };
|
||||||
|
|
||||||
|
return new UpdateInformation();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Eventing
|
#region Eventing
|
||||||
|
|
Loading…
Reference in a new issue