public void testCompareVersion() { Assert.IsTrue(UpdateUtils.CompareVersion("1.0.12", "0.0.3")); Assert.IsFalse(UpdateUtils.CompareVersion("0.0.2", "0.0.2")); Assert.IsTrue(UpdateUtils.CompareVersion("0.2", "0.1.2")); Assert.IsFalse(UpdateUtils.CompareVersion("XXXX", "1.2.3")); Assert.IsFalse(UpdateUtils.CompareVersion("0.2", "0.2.2")); Assert.IsTrue(UpdateUtils.CompareVersion("0.2.2", "0.2")); Assert.IsTrue(UpdateUtils.CompareVersion("3", "2.4.18")); Assert.IsFalse(UpdateUtils.CompareVersion("1.1.2.123", "1.1.2.")); }
/* * 1. get version number of remote server * 2. compare it with the version number of local running, if equal return. * 3. check if there is a package downloaded in the temporary directory. * 4. if there is not a package download the pacakge. * 5. ask user to update and restart. */ private void getVersionCallback(String versionXml) { ParseRemoteXml(versionXml); string localversion = UpdateUtils.GetVersionNumberFromFile("version.xml"); if (UpdateUtils.CompareVersion(RemoteVersionNumber, localversion)) // step 2 { if (PackageAlreadyDownload()) { DispatchUpdateInfo(null); } else { string str = DownloadThePackage(); DispatchUpdateInfo(str); } } else { return; } }