/// <summary> /// Initializes a new instance of the <see cref="CommandLineParser" /> class /// using possible arguments deducted from the specific <see cref="Type" />. /// </summary> /// <param name="argumentSpecification">The <see cref="Type" /> from which the possible command-line arguments should be retrieved.</param> /// <param name="supportsResponseFile">A <see cref="bool" /> value indicating whether or not a response file is able to be used. </param> /// <exception cref="ArgumentNullException"><paramref name="argumentSpecification" /> is a null reference.</exception> public CommandLineParser(Type argumentSpecification, bool supportsResponseFile) { if (argumentSpecification == null) { throw new ArgumentNullException("argumentSpecification"); } _argumentCollection = new CommandLineArgumentCollection(); foreach (PropertyInfo propertyInfo in argumentSpecification.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { if (propertyInfo.CanWrite || typeof(ICollection).IsAssignableFrom(propertyInfo.PropertyType)) { CommandLineArgumentAttribute attribute = GetCommandLineAttribute(propertyInfo); if (attribute is DefaultCommandLineArgumentAttribute) { Debug.Assert(_defaultArgument == null); _defaultArgument = new CommandLineArgument(attribute, propertyInfo); } else if (attribute != null) { _argumentCollection.Add(new CommandLineArgument(attribute, propertyInfo)); } } } _argumentSpecification = argumentSpecification; _supportsResponseFile = supportsResponseFile; }
/// <summary> /// Initializes a new instance of the <see cref="CommandLineParser" /> class /// using possible arguments deducted from the specific <see cref="Type" />. /// </summary> /// <param name="argumentSpecification">The <see cref="Type" /> from which the possible command-line arguments should be retrieved.</param> /// <param name="supportsResponseFile">A <see cref="bool" /> value indicating whether or not a response file is able to be used. </param> /// <exception cref="ArgumentNullException"><paramref name="argumentSpecification" /> is a null reference.</exception> public CommandLineParser(Type argumentSpecification, bool supportsResponseFile ) { if (argumentSpecification == null) { throw new ArgumentNullException("argumentSpecification"); } _argumentCollection = new CommandLineArgumentCollection(); foreach (PropertyInfo propertyInfo in argumentSpecification.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { if (propertyInfo.CanWrite || typeof(ICollection).IsAssignableFrom(propertyInfo.PropertyType)) { CommandLineArgumentAttribute attribute = GetCommandLineAttribute(propertyInfo); if (attribute is DefaultCommandLineArgumentAttribute) { Debug.Assert(_defaultArgument == null); _defaultArgument = new CommandLineArgument(attribute, propertyInfo); } else if (attribute != null) { _argumentCollection.Add(new CommandLineArgument(attribute, propertyInfo)); } } } _argumentSpecification = argumentSpecification; _supportsResponseFile = supportsResponseFile; }