public Parser(ParserSettings settings) { Assumes.NotNull(settings, "settings", SR.ArgumentNullException_ParserSettingsInstanceCannotBeNull); if (settings.Consumed) { throw new InvalidOperationException(SR.InvalidOperationException_ParserSettingsInstanceCanBeUsedOnce); } _settings = settings; _settings.Consumed = true; }
/// <summary> /// Initializes a new instance of the <see cref="Parser"/> class, /// configurable with <see cref="ParserSettings"/> using a delegate. /// </summary> /// <param name="configuration">The <see cref="Action<ParserSettings>"/> delegate used to configure /// aspects and behaviors of the parser.</param> public Parser(Action<ParserSettings> configuration) { Assumes.NotNull(configuration, "configuration", SR.ArgumentNullException_ParserSettingsDelegateCannotBeNull); _settings = new ParserSettings(); configuration.Invoke(Settings); _settings.Consumed = true; }
/// <summary> /// Initializes a new instance of the <see cref="CommandLine.Parser"/> class. /// </summary> public Parser() { _settings = new ParserSettings { Consumed = true }; }
private static StringComparison GetStringComparison(ParserSettings settings) { return settings.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; }