本文整理汇总了C#中System.Version.SimplifyVersion方法的典型用法代码示例。如果您正苦于以下问题:C# Version.SimplifyVersion方法的具体用法?C# Version.SimplifyVersion怎么用?C# Version.SimplifyVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Version
的用法示例。
在下文中一共展示了Version.SimplifyVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckForUpdates
internal static async void CheckForUpdates(bool silent)
{
var hc = new HttpClient();
try
{
var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
var uri = new Uri("http://wordslive.org/version.xml");
var str = await hc.GetStringAsync(uri);
var reader = new StringReader(str);
var doc = XDocument.Load(reader);
var latestVersion = new Version(doc.Root.Element("version").Value);
var noUpdateVersion = new Version(Properties.Settings.Default.NoUpdateVersion);
var latestUri = new Uri(doc.Root.Element("url").Value);
if (currentVersion >= latestVersion)
{
if (!silent)
{
MessageBox.Show(instance.window, Resource.updMsgUpToDate, "");
}
}
else if (!silent || noUpdateVersion < latestVersion)
{
var result = MessageBox.Show(instance.window, String.Format(Resource.updMsgNewVersion, latestVersion.SimplifyVersion().ToString()), "", MessageBoxButton.YesNoCancel);
if (result == MessageBoxResult.Yes)
{
// open download in browser and don't show update alert again
latestUri.OpenInBrowser();
Properties.Settings.Default.NoUpdateVersion = latestVersion.ToString();
}
else if (result == MessageBoxResult.No)
{
// don't show update alert again (until newer version is available)
Properties.Settings.Default.NoUpdateVersion = latestVersion.ToString();
}
}
}
catch (Exception)
{
if (!silent)
{
MessageBox.Show(instance.window, Resource.updMsgFailed, "", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}