Update() public method

public Update ( ) : UpdateInfo
return UpdateInfo
		public static void CheckForUpdates(string productName, string version)
		{
			const string productListUrl = "http://www.ijw.co.nz/products.xml";

			try
			{
				IUpdateProvider provider = XmlUpdateProvider.FromInternet(new Uri(productListUrl));
				UpdateManager manager = new UpdateManager(productName, version, provider);
				UpdateInfo info = manager.Update();

				if (info == null)
				{
					MessageBox.Show("You already have the latest version of " + productName,
						"Check for Updates", MessageBoxButtons.OK, MessageBoxIcon.Information);
					return;
				}

				string text = "A new version of {0} is available.\n" +
					"Your version: {1}\nLatest version: {2} (released {3})\n" +
					"Do you want to download it?";

				string hax = string.Format(text, productName, manager.Version, info.Version, info.LastUpdate.ToLongDateString());

				if (DialogResult.Yes == MessageBox.Show(hax, "Check for Updates", MessageBoxButtons.YesNo,
					MessageBoxIcon.Information))
				{
					Process.Start(info.Url.ToString());
				}
			}
			catch (Exception e)
			{
				MessageBox.Show("An error occurred while checking for updates.\n" + e.Message, "Check for Updates",
					MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
示例#2
0
		public void TestUnavailableProduct()
		{
			IUpdateProvider provider = new MockUpdateProvider();
			UpdateManager manager = new UpdateManager("Fake Product", "1.0", provider);

			UpdateInfo info = manager.Update();
			Assert.IsNull(info);
		}
示例#3
0
		public void TestHasNewerVersion()
		{
			MockUpdateProvider provider = new MockUpdateProvider();

			provider.AddProduct(new UpdateInfo("Fake Product", new Version("1.0"),
				tempuri, tempuri, DateTime.Now));

			UpdateManager manager = new UpdateManager("Fake Product", "2.0", provider);
			UpdateInfo update = manager.Update();

			Assert.IsNull(update);
		}