当前位置: 首页>>代码示例>>C#>>正文


C# Asset.IsNewVersion方法代码示例

本文整理汇总了C#中Asset.IsNewVersion方法的典型用法代码示例。如果您正苦于以下问题:C# Asset.IsNewVersion方法的具体用法?C# Asset.IsNewVersion怎么用?C# Asset.IsNewVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Asset的用法示例。


在下文中一共展示了Asset.IsNewVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Http_DownloadStringCompleted

        private void Http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                string response = e.Result;

                JArray result = JArray.Parse(response);
                List<Asset> asserts = new List<Asset>();

                bool hasBeta = false;
                bool hasStable = false;

                if (result != null)
                {
                    foreach (JObject release in result)
                    {
                        if ((bool)release["prerelease"])
                        {
                            if (!hasBeta)
                            {
                                Asset ass = new Asset();
                                ass.Parase(release);
                                if (ass.IsNewVersion(Version))
                                {
                                    asserts.Add(ass);
                                    hasBeta = true;
                                }
                            }
                        }
                        else
                        {
                            Asset ass = new Asset();
                            ass.Parase(release);
                            if (ass.IsNewVersion(Version))
                            {
                                asserts.Add(ass);
                                hasStable = true;
                            }
                            break;
                        }
                    }
                }

                if (asserts.Count != 0)
                {
                    foreach (Asset ass in asserts)
                    {
                        Log.Info($"发现新版本{ass.name}" + (ass.prerelease ? "beta" : ""));
                    }
                    int stable = asserts.Count - 1;
                    string changelog = "更新日志获取失败惹 T T";
                    try
                    {
                        changelog = BiliInterface.GetHtml("https://raw.githubusercontent.com/SkiTiSu/BiliRanking/master/BiliRanking/changelog.txt");
                        changelog = changelog.Substring(0, changelog.IndexOf("\n\n"));
                    }
                    catch
                    {
                        Log.Warn("更新日志获取失败");
                    }
                    if (!checkBeta && hasStable)
                    {
                        DialogResult res = MessageBox.Show($"发现新版本{asserts[stable].name}啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            StartDownload(asserts[stable]);
                        }
                        else
                        {
                            Log.Info("更新被取消");
                        }
                    }
                    else if(checkBeta && (hasBeta || hasStable))
                    {
                        DialogResult res = MessageBox.Show($"发现新版本{asserts[0].name}beta啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            StartDownload(asserts[0]);
                        }
                        else
                        {
                            Log.Info("更新被取消");
                        }
                    }
                    else
                    {
                        Log.Info("没有符合要求的更新");
                    }
                }
                else
                {
                    Log.Info("没有发现新版本");
                }

            }
            catch (Exception ex)
            {
                Log.Error("检查更新失败 - 解析json失败");
                Log.Debug(ex.Message);
            }
//.........这里部分代码省略.........
开发者ID:SkiTiSu,项目名称:BiliRanking,代码行数:101,代码来源:Updater.cs


注:本文中的Asset.IsNewVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。