protected static void EnsureOptionArrayAttributeIsNotBoundToScalar(OptionInfo option) { if (!option.IsArray && option.IsAttributeArrayCompatible) { throw new CommandLineParserException(); } }
public OptionInfo this[string key] { get { OptionInfo option = null; if (_map.ContainsKey(key)) { option = _map[key]; } else { string optionKey = null; if (_names.ContainsKey(key)) { optionKey = _names[key]; option = _map[optionKey]; } } return(option); } set { _map[key] = value; if (value.HasBothNames) { _names[value.LongName] = value.ShortName; } } }
private void BuildMutuallyExclusiveMap(OptionInfo option) { var setName = option.MutuallyExclusiveSet; if (!_mutuallyExclusiveSetMap.ContainsKey(setName)) { _mutuallyExclusiveSetMap.Add(setName, 0); } _mutuallyExclusiveSetMap[setName]++; }
private bool DoParseArguments(string[] args, object options) { bool hadError = false; var optionMap = OptionInfo.CreateMap(options, _settings); var target = new TargetWrapper(options); IArgumentEnumerator arguments = new StringArrayEnumerator(args); while (arguments.MoveNext()) { string argument = arguments.Current; if (argument != null && argument.Length > 0) { ArgumentParser parser = ArgumentParser.Create(argument); //, target); if (parser != null) { ParserState result = parser.Parse(arguments, optionMap, options); if ((result & ParserState.Failure) == ParserState.Failure) { hadError = true; break; } if ((result & ParserState.MoveOnNextElement) == ParserState.MoveOnNextElement) { arguments.MoveNext(); } } else if (target.IsValueListDefined) { if (!target.AddValueItemIfAllowed(argument)) { hadError = true; break; } } } } hadError |= !optionMap.EnforceRules(); return(!hadError); }
private void BuildMutuallyExclusiveMap(OptionInfo option) { var setName = option.MutuallyExclusiveSet; if (!_mutuallyExclusiveSetMap.ContainsKey(setName)) _mutuallyExclusiveSetMap.Add(setName, 0); _mutuallyExclusiveSetMap[setName]++; }
protected static void EnsureOptionArrayAttributeIsNotBoundToScalar(OptionInfo option) { if (!option.IsArray && option.IsAttributeArrayCompatible) throw new CommandLineParserException(); }
protected static void EnsureOptionAttributeIsArrayCompatible(OptionInfo option) { if (!option.IsAttributeArrayCompatible) throw new CommandLineParserException(); }