using System; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; using System.IO; using System.Xml; using System.Reflection; namespace OnTopReplica.Update { /// /// Contains information about the latest OnTopReplica update available. /// public class UpdateInformation { Version _latestVersion; /// /// Gets the latest available version of the software. /// [XmlIgnore] public Version LatestVersion { get { return _latestVersion; } set { _latestVersion = value; } } [XmlElement("latestVersion")] public string LatestVersionInternal { get { return _latestVersion.ToString(); } set { _latestVersion = new Version(value); } } /// /// Returns whether this update information instance represents data about /// a new available version. /// public bool IsNewVersion { get { var currentVersion = CurrentVersion; return (LatestVersion > currentVersion); } } /// /// Gets the currently installed version. /// public Version CurrentVersion { get { return Assembly.GetExecutingAssembly().GetName().Version; } } /// /// Indicates when the latest version was released. /// [XmlElement("latestVersionRelease")] public DateTime LatestVersionRelease { get; set; } /// /// Gets the URL of the page that allows the user to download the updated installer. /// [XmlElement("downloadPage")] public string DownloadPage { get; set; } /// /// Gets the URL of the installer executable. /// /// New after version 3.3.1. [XmlElement("downloadInstaller")] public string DownloadInstaller { get; set; } /// /// Deserializes an UpdateInformation object from a stream. /// public static UpdateInformation Deserialize(Stream source) { var serializer = new XmlSerializer(typeof(UpdateInformation)); var info = serializer.Deserialize(source) as UpdateInformation; return info; } } }