Code refactoring

This commit is contained in:
Jaex 2022-10-15 01:46:28 +03:00
parent cc63d784a6
commit cd22e384e2
4 changed files with 12 additions and 17 deletions

View file

@ -39,9 +39,9 @@ public CLICommand(string command = null, string parameter = null)
Parameter = parameter;
}
public bool CheckCommand(string command)
public bool CheckCommand(string command, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
{
return !string.IsNullOrEmpty(Command) && Command.Equals(command, StringComparison.InvariantCultureIgnoreCase);
return !string.IsNullOrEmpty(Command) && Command.Equals(command, comparisonType);
}
public override string ToString()

View file

@ -285,7 +285,7 @@ public static bool OpenFile(string filePath)
return false;
}
public static bool OpenFolder(string folderPath)
public static bool OpenFolder(string folderPath, bool allowMessageBox = true)
{
if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
{
@ -316,7 +316,7 @@ public static bool OpenFolder(string folderPath)
DebugHelper.WriteException(e, $"OpenFolder({folderPath}) failed.");
}
}
else
else if (allowMessageBox)
{
MessageBox.Show(Resources.Helpers_OpenFolder_Folder_not_exist_ + Environment.NewLine + folderPath, "ShareX",
MessageBoxButtons.OK, MessageBoxIcon.Information);

View file

@ -198,7 +198,7 @@ private static void Main(string[] args)
if (Job.HasFlag(SetupJobs.OpenOutputDirectory))
{
OpenOutputDirectory();
FileHelpers.OpenFolder(OutputDir, false);
}
Console.WriteLine("ShareX setup successfully completed.");
@ -238,6 +238,12 @@ private static void CheckArgs(string[] args)
}
}
private static string GetAppVersion()
{
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ExecutablePath);
return $"{versionInfo.ProductMajorPart}.{versionInfo.ProductMinorPart}.{versionInfo.ProductBuildPart}";
}
private static void CompileSetup()
{
CompileISSFile("Recorder-devices-setup.iss");
@ -366,16 +372,5 @@ private static void DownloadFFmpeg()
ZipManager.Extract(filePath, OutputDir, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase), 200_000_000);
}
}
private static void OpenOutputDirectory()
{
Process.Start(OutputDir);
}
private static string GetAppVersion()
{
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ExecutablePath);
return $"{versionInfo.ProductMajorPart}.{versionInfo.ProductMinorPart}.{versionInfo.ProductBuildPart}";
}
}
}

View file

@ -77,7 +77,7 @@ public static void CopyFiles(string directory, string searchPattern, string toFo
{
string fileName = Path.GetFileName(file);
if (ignoreFiles.All(x => !fileName.Equals(x, StringComparison.InvariantCultureIgnoreCase)))
if (ignoreFiles.All(x => !fileName.Equals(x, StringComparison.OrdinalIgnoreCase)))
{
newFiles.Add(file);
}