SharedParameters.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace fis.Loader.Parameters
  7. {
  8. internal class SharedParameters
  9. {
  10. /// <summary>
  11. /// 参数字典
  12. /// </summary>
  13. internal static readonly Dictionary<string, string> Parameters = new Dictionary<string, string>();
  14. /// <summary>
  15. /// 装载
  16. /// </summary>
  17. /// <param name="args"></param>
  18. internal static void Load(string[] args)
  19. {
  20. foreach (string arg in args)
  21. {
  22. if (arg.StartsWith("-") == false)
  23. {
  24. continue;
  25. }
  26. foreach (string key in SharedParameterKeys.AllKeys)
  27. {
  28. if (arg.StartsWith($"-{key}"))
  29. {
  30. Parameters.Add(key, GetArgValue(arg));
  31. break;
  32. }
  33. }
  34. }
  35. }
  36. private static string GetArgValue(string arg)
  37. {
  38. var index = arg.IndexOf('=');
  39. if (index > 0)
  40. {
  41. return arg.Substring(index + 1, arg.Length - index - 1);
  42. }
  43. return string.Empty;
  44. }
  45. }
  46. }