using ApplicationUpgradeManager.Core.Model; using SpaceEngineersBlueprintEditor.Profiles; using System.Diagnostics; using System.Reflection; using XFEExtension.NetCore.UpgradeHelper.Utilities; namespace SpaceEngineersBlueprintEditor.Utilities.Helpers; public static class UpgradeHelper { public static string RequestAddress => UnloadProfile.ServerUrl; public static Upgrader Upgrader { get; set; } = new(RequestAddress); public static Version Version => Assembly.GetExecutingAssembly().GetName().Version ?? new Version(1, 0, 0); /// /// 检测是否需要更新 /// /// public static async Task NeedUpgrade() => (await Upgrader.GetReleaseNotes("太空工程师蓝图编辑器", Version.ToString())).IsLatest; /// /// 获取更新信息 /// /// public static async Task GetReleaseNotes() => await Upgrader.GetReleaseNotes("太空工程师蓝图编辑器", Version.ToString()); /// /// 开始更新 /// public static void StartUpdate(string downloadUrl) { var startInfo = new ProcessStartInfo("SpaceEngineersBlueprintEditor.Installer.exe") { UseShellExecute = true, Verb = "runas" }; startInfo.ArgumentList.Add("Upgrade"); startInfo.ArgumentList.Add(downloadUrl); startInfo.ArgumentList.Add(""); Process.Start(startInfo); Process.GetCurrentProcess().Kill(); Application.Current.Exit(); } }