private void responseHandler(string type, string redirectUrl) { try { string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); string curVersion; string message; string url; if (type == "v2fly") { curVersion = "v" + getCoreVersion(type); message = string.Format(UIRes.I18N("IsLatestCore"), curVersion); string osBit = Environment.Is64BitProcess ? "64" : "32"; url = string.Format(v2flyCoreUrl, version, osBit); } else if (type == "xray") { curVersion = "v" + getCoreVersion(type); message = string.Format(UIRes.I18N("IsLatestCore"), curVersion); string osBit = Environment.Is64BitProcess ? "64" : "32"; url = string.Format(xrayCoreUrl, version, osBit); } else if (type == "v2rayN") { curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); message = string.Format(UIRes.I18N("IsLatestN"), curVersion); url = string.Format(nUrl, version); } else { throw new ArgumentException("Type"); } if (curVersion == version) { AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message)); return; } AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url)); } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); Error?.Invoke(this, new ErrorEventArgs(ex)); } }
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease) { try { var gitHubReleases = Utils.FromJson <List <GitHubRelease> >(gitHubReleaseApi); string version; if (preRelease) { version = gitHubReleases !.First().TagName; } else { version = gitHubReleases !.First(r => r.Prerelease == false).TagName; } var coreInfo = LazyConfig.Instance.GetCoreInfo(type); string curVersion; string message; string url; switch (type) { case ECoreType.v2fly: case ECoreType.SagerNet: case ECoreType.Xray: { curVersion = "v" + getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); string osBit = Environment.Is64BitProcess ? "64" : "32"; url = string.Format(coreInfo.coreDownloadUrl64, version, osBit); break; } case ECoreType.clash: case ECoreType.clash_meta: { curVersion = getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); if (Environment.Is64BitProcess) { url = string.Format(coreInfo.coreDownloadUrl64, version); } else { url = string.Format(coreInfo.coreDownloadUrl32, version); } break; } case ECoreType.v2rayN: { curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); message = string.Format(ResUI.IsLatestN, curVersion); url = string.Format(coreInfo.coreDownloadUrl64, version); break; } default: throw new ArgumentException("Type"); } if (curVersion == version) { AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message)); return; } AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url)); } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); _updateFunc(false, ex.Message); } }
private void responseHandler(ECoreType type, string redirectUrl) { try { string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); var coreInfo = LazyConfig.Instance.GetCoreInfo(type); string curVersion; string message; string url; switch (type) { case ECoreType.v2fly: case ECoreType.Xray: { curVersion = "v" + getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); string osBit = Environment.Is64BitProcess ? "64" : "32"; url = string.Format(coreInfo.coreDownloadUrl64, version, osBit); break; } case ECoreType.clash: case ECoreType.clash_meta: { curVersion = ""; //getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); if (Environment.Is64BitProcess) { url = string.Format(coreInfo.coreDownloadUrl64, version); } else { url = string.Format(coreInfo.coreDownloadUrl32, version); } break; } case ECoreType.v2rayN: { curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); message = string.Format(ResUI.IsLatestN, curVersion); url = string.Format(coreInfo.coreDownloadUrl64, version); break; } default: throw new ArgumentException("Type"); } if (curVersion == version) { AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message)); return; } AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url)); } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); _updateFunc(false, ex.Message); } }