-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for dynamically created culture info, rider refactor
- Loading branch information
Showing
17 changed files
with
9,030 additions
and
9,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
using System; | ||
|
||
namespace InsaneGenius.Utilities | ||
namespace InsaneGenius.Utilities; | ||
|
||
public static class CommandLineEx | ||
{ | ||
public static class CommandLineEx | ||
// https://stackoverflow.com/questions/298830/split-string-containing-command-line-parameters-into-string-in-c-sharp | ||
public static string[] ParseArguments(string commandLine) | ||
{ | ||
// https://stackoverflow.com/questions/298830/split-string-containing-command-line-parameters-into-string-in-c-sharp | ||
public static string[] ParseArguments(string commandLine) | ||
{ | ||
if (commandLine == null) | ||
throw new ArgumentNullException(nameof(commandLine)); | ||
if (commandLine == null) | ||
throw new ArgumentNullException(nameof(commandLine)); | ||
|
||
char[] paramChars = commandLine.ToCharArray(); | ||
bool inQuote = false; | ||
for (int index = 0; index < paramChars.Length; index++) | ||
{ | ||
if (paramChars[index] == '"') | ||
inQuote = !inQuote; | ||
if (!inQuote && paramChars[index] == ' ') | ||
paramChars[index] = '\n'; | ||
} | ||
return new string(paramChars).Split('\n'); | ||
char[] paramChars = commandLine.ToCharArray(); | ||
bool inQuote = false; | ||
for (int index = 0; index < paramChars.Length; index++) | ||
{ | ||
if (paramChars[index] == '"') | ||
inQuote = !inQuote; | ||
if (!inQuote && paramChars[index] == ' ') | ||
paramChars[index] = '\n'; | ||
} | ||
return new string(paramChars).Split('\n'); | ||
} | ||
|
||
public static string[] GetCommandLineArgs() | ||
{ | ||
// Split the arguments | ||
string[] args = ParseArguments(Environment.CommandLine); | ||
public static string[] GetCommandLineArgs() | ||
{ | ||
// Split the arguments | ||
string[] args = ParseArguments(Environment.CommandLine); | ||
|
||
// Strip the process path from the list of arguments | ||
string[] argsEx = new string[args.Length - 1]; | ||
Array.Copy(args, 1, argsEx, 0, argsEx.Length); | ||
return argsEx; | ||
} | ||
// Strip the process path from the list of arguments | ||
string[] argsEx = new string[args.Length - 1]; | ||
Array.Copy(args, 1, argsEx, 0, argsEx.Length); | ||
return argsEx; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,83 @@ | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace InsaneGenius.Utilities | ||
namespace InsaneGenius.Utilities; | ||
|
||
public static class ConsoleEx | ||
{ | ||
public static class ConsoleEx | ||
public static void WriteLineColor(ConsoleColor color, string value) | ||
{ | ||
public static void WriteLineColor(ConsoleColor color, string value) | ||
// Locking only works when using this function | ||
// Mixing any other console output may still result in mismatched color output | ||
lock (WriteLineLock) | ||
{ | ||
// Locking only works when using this function | ||
// Mixing any other console output may still result in mismatched color output | ||
lock (WriteLineLock) | ||
{ | ||
ConsoleColor oldColor = Console.ForegroundColor; | ||
Console.ForegroundColor = color; | ||
Console.WriteLine(string.IsNullOrEmpty(value) ? $"{value}" : $"{DateTime.Now.ToString(CultureInfo.CurrentCulture)} : {value}"); | ||
Console.ForegroundColor = oldColor; | ||
} | ||
ConsoleColor oldColor = Console.ForegroundColor; | ||
Console.ForegroundColor = color; | ||
Console.WriteLine(string.IsNullOrEmpty(value) ? $"{value}" : $"{DateTime.Now.ToString(CultureInfo.CurrentCulture)} : {value}"); | ||
Console.ForegroundColor = oldColor; | ||
} | ||
public static void WriteLineColor(ConsoleColor color, object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
} | ||
public static void WriteLineColor(ConsoleColor color, object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
WriteLineColor(color, value.ToString()); | ||
} | ||
WriteLineColor(color, value.ToString()); | ||
} | ||
|
||
public static void WriteLineError(string value) | ||
{ | ||
WriteLineColor(ErrorColor, value); | ||
} | ||
public static void WriteLineError(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
public static void WriteLineError(string value) | ||
{ | ||
WriteLineColor(ErrorColor, value); | ||
} | ||
public static void WriteLineError(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
WriteLineError(value.ToString()); | ||
} | ||
WriteLineError(value.ToString()); | ||
} | ||
|
||
public static void WriteLineEvent(string value) | ||
{ | ||
WriteLineColor(EventColor, value); | ||
} | ||
public static void WriteLineEvent(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
public static void WriteLineEvent(string value) | ||
{ | ||
WriteLineColor(EventColor, value); | ||
} | ||
public static void WriteLineEvent(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
WriteLineEvent(value.ToString()); | ||
} | ||
WriteLineEvent(value.ToString()); | ||
} | ||
|
||
public static void WriteLineTool(string value) | ||
{ | ||
WriteLineColor(ToolColor, value); | ||
} | ||
public static void WriteLineTool(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
public static void WriteLineTool(string value) | ||
{ | ||
WriteLineColor(ToolColor, value); | ||
} | ||
public static void WriteLineTool(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
WriteLineTool(value.ToString()); | ||
} | ||
WriteLineTool(value.ToString()); | ||
} | ||
|
||
public static void WriteLine(string value) | ||
{ | ||
WriteLineColor(OutputColor, value); | ||
} | ||
public static void WriteLine(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
public static void WriteLine(string value) | ||
{ | ||
WriteLineColor(OutputColor, value); | ||
} | ||
public static void WriteLine(object value) | ||
{ | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
WriteLine(value.ToString()); | ||
} | ||
WriteLine(value.ToString()); | ||
} | ||
|
||
private static readonly object WriteLineLock = new object(); | ||
private static readonly object WriteLineLock = new(); | ||
|
||
// Good looking console colors; Green, Cyan, Red, Magenta, Yellow, White | ||
public const ConsoleColor ToolColor = ConsoleColor.Green; | ||
public const ConsoleColor ErrorColor = ConsoleColor.Red; | ||
public const ConsoleColor OutputColor = ConsoleColor.Cyan; | ||
public const ConsoleColor EventColor = ConsoleColor.Yellow; | ||
} | ||
} | ||
// Good looking console colors; Green, Cyan, Red, Magenta, Yellow, White | ||
public const ConsoleColor ToolColor = ConsoleColor.Green; | ||
public const ConsoleColor ErrorColor = ConsoleColor.Red; | ||
public const ConsoleColor OutputColor = ConsoleColor.Cyan; | ||
public const ConsoleColor EventColor = ConsoleColor.Yellow; | ||
} |
Oops, something went wrong.