private void UpdateOptionValue(ConsoleArgument option, string[] arguments, ref bool[] updatedArgs) { object defaultValue = option.Value; var re = new Regex(option.Pattern); string arg; for (int i = 0; i < arguments.Length; i++) { if (updatedArgs[i] || !re.IsMatch(arg = arguments[i])) { continue; } updatedArgs[i] = true; if (defaultValue is bool) { option.Value = true; } else { var value = arg.Substring(arg.IndexOf('=') + 1).Trim('"'); if (defaultValue is string[]) { option.Value = value.Split(','); } else if (defaultValue is int) { option.Value = int.Parse(value); } } return; } }
private void UpdateOptionValue(ConsoleArgument option, string[] arguments, ref bool[] updatedArgs) { object defaultValue = option.Value; var re = new Regex(option.Pattern); string arg; for (int i = 0; i < arguments.Length; i++) { if (updatedArgs[i] || !re.IsMatch(arg = arguments[i])) continue; updatedArgs[i] = true; if (defaultValue is bool) { option.Value = true; } else { var value = arg.Substring(arg.IndexOf('=') + 1).Trim('"'); if (defaultValue is string[]) { option.Value = value.Split(','); } else if (defaultValue is int) { option.Value = int.Parse(value); } } return; } }