CommandLineArgs.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace NTMiner {
  5. public static partial class CommandLineArgs {
  6. private static readonly List<string> s_commandLineArgs = Environment.GetCommandLineArgs().Skip(1).ToList();
  7. public static List<string> Args {
  8. get {
  9. return s_commandLineArgs;
  10. }
  11. }
  12. private static string PickArgument(string argumentName) {
  13. string result = string.Empty;
  14. int index = -1;
  15. for (int i = 0; i < s_commandLineArgs.Count; i++) {
  16. string item = s_commandLineArgs[i];
  17. if (item.StartsWith(argumentName)) {
  18. string[] parts = item.Split('=');
  19. if (parts.Length == 2) {
  20. result = parts[1];
  21. index = i;
  22. break;
  23. }
  24. }
  25. }
  26. if (string.IsNullOrEmpty(result) && index != -1) {
  27. s_commandLineArgs.RemoveAt(index);
  28. }
  29. return result;
  30. }
  31. }
  32. }