public OptionMap(int capacity, CommandLineParserSettings settings) { _settings = settings; IEqualityComparer<string> comparer = _settings.CaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase; _names = new Dictionary<string, string>(capacity, comparer); _map = new Dictionary<string, OptionInfo>(capacity * 2, comparer); if (_settings.MutuallyExclusive) { _mutuallyExclusiveSetMap = new Dictionary<string, MutuallyExclusiveInfo>(capacity, StringComparer.OrdinalIgnoreCase); } }
// special constructor for singleton instance, parameter ignored private CommandLineParser(bool singleton) { Singleton = singleton; _settings = new CommandLineParserSettings(false, false, Console.Error); }
/// <summary> /// Initializes a new instance of the <see cref="CommandLineParser"/> class, /// configurable with a <see cref="CommandLineParserSettings"/> object. /// </summary> /// <param name="settings">The <see cref="CommandLineParserSettings"/> object is used to configure /// aspects and behaviors of the parser.</param> public CommandLineParser(CommandLineParserSettings settings) { _settings = settings; }
/// <summary> /// Initializes a new instance of the <see cref="CommandLineParser"/> class. /// </summary> public CommandLineParser() { _settings = new CommandLineParserSettings(); }
public static OptionMap CreateMap(object target, CommandLineParserSettings settings) { var list = ReflectionUtil.RetrievePropertyList<OptionAttribute>(target); if (list != null) { var map = new OptionMap(list.Count, settings); foreach (var pair in list.Where(pair => pair != null && pair.Right != null)) { map[pair.Right.UniqueName] = new OptionInfo(pair.Right, pair.Left); } map.RawOptions = target; return map; } return null; }