public void TestStringRepresentation() { BinaryVersion version = BinaryVersion.FromString("12.34.56.78"); Assert.AreNotEqual(null, version); Assert.AreEqual("12.34.56.78", version.ToString()); }
/// <summary> /// Async call to request downloading a file from web. /// This call raises UpdateDownloaded event notification. /// </summary> /// <param name="url">Web URL for file to download.</param> /// <param name="version">The version of package that is to be downloaded.</param> /// <returns>Request status, it may return false if invalid URL was passed.</returns> private bool DownloadUpdatePackage(string url, BinaryVersion version) { if (string.IsNullOrEmpty(url) || (null == version)) { versionCheckInProgress = false; return(false); } UpdateFileLocation = string.Empty; string downloadedFileName = string.Empty; string downloadedFilePath = string.Empty; try { downloadedFileName = Path.GetFileNameWithoutExtension(url); downloadedFileName += "." + version.ToString() + Path.GetExtension(url); downloadedFilePath = Path.Combine(Path.GetTempPath(), downloadedFileName); if (File.Exists(downloadedFilePath)) { File.Delete(downloadedFilePath); } } catch (Exception) { versionCheckInProgress = false; return(false); } WebClient client = new WebClient(); client.DownloadFileCompleted += new AsyncCompletedEventHandler(OnDownloadFileCompleted); client.DownloadFileAsync(new Uri(url), downloadedFilePath, downloadedFilePath); return(true); }