コード例 #1
0
 private CommandLineOption GetOptionOrNull(string name)
 {
     name = CommandLineOption.Normalize(name);
     if (!_options.TryGetValue(name, out var result))
     {
         return(null);
     }
     return(result);
 }
コード例 #2
0
        private CommandLineOption GetOptionOrNull(char ch)
        {
            var name = CommandLineOption.Normalize(ch);

            if (!_options.TryGetValue(name, out var result))
            {
                return(null);
            }
            return(result);
        }
コード例 #3
0
        private void ValidateAndAddOption(CommandLineOption option, int i)
        {
            if (option.LongName != null)
            {
                Debug.Assert(!string.IsNullOrWhiteSpace(option.LongName));
                if (_options.TryGetValue(option.LongName, out _))
                {
                    throw new ArgumentException($"INTERNAL ERROR: options[{i}] is {option.LongName}, which was specified before.");
                }
                _options[option.LongName] = option;
            }

            if (option.ShortName != null)
            {
                Debug.Assert(!string.IsNullOrWhiteSpace(option.ShortName));
                if (_options.TryGetValue(option.ShortName, out _))
                {
                    throw new ArgumentException($"INTERNAL ERROR: options[{i}] is {option.ShortName}, which was specified before.");
                }
                _options[option.ShortName] = option;
            }
        }
コード例 #4
0
 private void AddCharOption(ICollection <CommandLineArgument> result, CommandLineOption option, int argIndex, string arg, int charIndex, string value)
 {
     result.Add(new CommandLineArgument(this, option, argIndex, arg, charIndex, value));
 }