123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.IO;
- using System.Xml;
- namespace Microsoft.Samples.AppUpdater
- {
- public class ServerManifest
- {
- private XmlDocument _manifest;
- private string _url;
- private string _AvailableVersion;
- private string _ApplicationUrl;
- public string AvailableVersion
- {
- get
- {
- return _AvailableVersion;
- }
- set
- {
- _AvailableVersion = value;
- }
- }
- public string ApplicationUrl
- {
- get
- {
- return _ApplicationUrl;
- }
- set
- {
- _ApplicationUrl = value;
- }
- }
- public DateTime LastModTime => WebFileLoader.GetLastModTime(_url);
- public void Load(string url)
- {
- _url = url;
- string text = AppDomain.CurrentDomain.BaseDirectory + Path.GetFileName(new Uri(_url).LocalPath);
- WebFileLoader.UpdateFile(_url, text);
- _manifest = new XmlDocument();
- _manifest.Load(text);
- ApplicationUrl = _manifest.GetElementsByTagName("ApplicationUrl")[0].InnerText;
- ApplicationUrl = ApplicationUrl.Replace("[DownLoadURL]", url.Replace("/UpdateVersion.xml", ""));
- AvailableVersion = _manifest.GetElementsByTagName("AvailableVersion")[0].InnerText;
- }
- public bool IsServerVersionNewer(Version currentVersion)
- {
- Version v = new Version(AvailableVersion);
- if (v > currentVersion)
- {
- return true;
- }
- return false;
- }
- }
- }
|