public Argument(CommandLineArgumentAttribute attribute, FieldInfo field, ErrorReporter reporter) { this.longName = CommandLineArgumentParser.LongName(attribute, field); this.description = CommandLineArgumentParser.Description(attribute); this.explicitShortName = CommandLineArgumentParser.ExplicitShortName(attribute); this.shortName = CommandLineArgumentParser.ShortName(attribute, field); this.elementType = ElementType(field); this.flags = Flags(attribute, field); this.field = field; this.seenValue = false; this.reporter = reporter; this.isDefault = (attribute != null) && (attribute is DefaultCommandLineArgumentAttribute); if (this.IsCollection) { this.collectionValues = new ArrayList(); } Debug.Assert( !string.IsNullOrEmpty(this.longName), "The long name must be provided for the argument."); Debug.Assert( !this.IsCollection || this.AllowMultiple, "Collection arguments must have allow multiple"); Debug.Assert( !this.Unique || this.IsCollection, "Unique only applicable to collection arguments"); Debug.Assert( IsValidElementType(this.Type) || IsCollectionType(this.Type), "The argument type is not valid."); Debug.Assert( (this.IsCollection && IsValidElementType(this.elementType)) || (!this.IsCollection && this.elementType == null), "The argument type is not valid."); }
/// <summary> /// Parses Command Line Arguments. /// Use CommandLineArgumentAttributes to control parsing behaviour. /// </summary> /// <param name="arguments"> The actual arguments. </param> /// <param name="destination"> The resulting parsed arguments. </param> /// <param name="reporter"> The destination for parse errors. </param> /// <returns> true if no errors were detected. </returns> public static bool ParseCommandLineArguments(string[] arguments, object destination, ErrorReporter reporter) { var parser = new CommandLineArgumentParser(destination.GetType(), reporter); return(parser.Parse(arguments, destination)); }