static private (Version, string) GetVersionAndChecksum(WebClientEx client, bool useGitHub) { SystemManager.CheckServerCertificate(useGitHub ? Globals.CheckUpdateGitHubURL : Globals.CheckUpdateURL, useGitHub, true); List <string> lines; try { string path = useGitHub ? Globals.CheckUpdateGitHubURL : Globals.CheckUpdateURL; lines = client.DownloadString(path).SplitNoEmptyLines(useGitHub).Take(2).ToList(); } catch (Exception ex) { throw new WebException(SysTranslations.CheckUpdateReadError.GetLang(ex.Message)); } LoadingForm.Instance.DoProgress(); var list = new NullSafeOfStringDictionary <string>(); foreach (string line in lines) { var parts = line.Split(':'); if (parts.Length != 2) { continue; } list.Add(parts[0].Trim(), parts[1].Trim()); } string fileVersion = list["Version"]; string fileChecksum = list["Checksum"]; if (fileVersion.IsNullOrEmpty() || fileChecksum.IsNullOrEmpty()) { throw new WebException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine())); } var partsVersion = fileVersion.Split('.'); Version version; try { version = partsVersion.Length switch { 2 => new Version(Convert.ToInt32(partsVersion[0]), Convert.ToInt32(partsVersion[1])), 3 => new Version(Convert.ToInt32(partsVersion[0]), Convert.ToInt32(partsVersion[1]), Convert.ToInt32(partsVersion[2])), 4 => new Version(Convert.ToInt32(partsVersion[0]), Convert.ToInt32(partsVersion[1]), Convert.ToInt32(partsVersion[2]), Convert.ToInt32(partsVersion[3])), _ => throw new ArgumentException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine())), }; } catch (Exception ex) { throw new WebException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine()) + Globals.NL2 + ex.Message); } LoadingForm.Instance.DoProgress(); return(version, fileChecksum); }