private static AIRVersionData GetDataFromEXE(string destination, bool isAdding) { AIRVersionData data; if (destination == null || destination == "" || !Directory.Exists(destination)) { return(LastResortVersionMethod(destination, isAdding)); } string exe = Directory.GetFiles(destination, "Sonic3AIR.exe", SearchOption.AllDirectories).FirstOrDefault(); if (exe != null && exe != "") { var versInfo = FileVersionInfo.GetVersionInfo(exe); string fileVersionFull2 = $"{versInfo.FileMajorPart.ToString().PadLeft(2, '0')}.{versInfo.FileMinorPart.ToString().PadLeft(2, '0')}.{versInfo.FileBuildPart.ToString().PadLeft(2, '0')}.{versInfo.FilePrivatePart.ToString()}"; if (Version.TryParse(fileVersionFull2, out Version result)) { data = new AIRVersionData(result, fileVersionFull2, new AIR_API.VersionMetadata(result, fileVersionFull2)); } else { data = new AIRVersionData(null, fileVersionFull2, new AIR_API.VersionMetadata(null, fileVersionFull2)); } DataRefrence.Add(destination, data); return(data); } else { return(LastResortVersionMethod(destination, isAdding)); } }
private static AIRVersionData LastResortVersionMethod(string destination, bool isAdding) { if (isAdding) { string exceptionVersion = ""; DialogResult result; result = ExtraDialog.ShowInputDialog(ref exceptionVersion, "", Management.UserLanguage.GetOutputString("VersionSelectCaption1")); while (Directory.Exists($"{exceptionVersion}") && !Uri.IsWellFormedUriString($"{exceptionVersion}", UriKind.Absolute) && (result != System.Windows.Forms.DialogResult.Cancel || result != System.Windows.Forms.DialogResult.Abort)) { result = ExtraDialog.ShowInputDialog(ref exceptionVersion, "", Management.UserLanguage.GetOutputString("VersionSelectCaption2")); } AIRVersionData data; data = new AIRVersionData(null, exceptionVersion, null); DataRefrence.Add(destination, data); return(data); } else { if (destination == null || destination == "" || !Directory.Exists(destination)) { destination = "NULL"; } var data = AIRVersionData.NullableDefault(); if (!DataRefrence.ContainsKey(destination)) { DataRefrence.Add(destination, data); } return(data); } }
private static AIRVersionData ReturnUsingMetadata(string destination, AIR_API.VersionMetadata meta) { var data = new AIRVersionData(meta.Version, meta.VersionString, meta); DataRefrence.Add(destination, data); return(data); }