1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace fis.Loader.Parameters
- {
- internal class SharedParameters
- {
- /// <summary>
- /// 参数字典
- /// </summary>
- internal static readonly Dictionary<string, string> Parameters = new Dictionary<string, string>();
- /// <summary>
- /// 装载
- /// </summary>
- /// <param name="args"></param>
- internal static void Load(string[] args)
- {
- foreach (string arg in args)
- {
- if (arg.StartsWith("-") == false)
- {
- continue;
- }
- foreach (string key in SharedParameterKeys.AllKeys)
- {
- if (arg.StartsWith($"-{key}"))
- {
- Parameters.Add(key, GetArgValue(arg));
- break;
- }
- }
- }
- }
- private static string GetArgValue(string arg)
- {
- var index = arg.IndexOf('=');
- if (index > 0)
- {
- return arg.Substring(index + 1, arg.Length - index - 1);
- }
- return string.Empty;
- }
- }
- }
|