public Argument(CommandLineArgumentAttribute attribute, FieldInfo field, ErrorReporter reporter) { this.LongName = LongName(attribute, field); this.Description = Description(attribute); this.ExplicitShortName = ExplicitShortName(attribute); this.ShortName = 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(this.LongName != null && this.LongName.Length > 0); 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)); Debug.Assert((this.IsCollection && IsValidElementType(this.elementType)) || (!this.IsCollection && this.elementType == null)); }
private static CommandLineArgumentType Flags(CommandLineArgumentAttribute attribute, FieldInfo field) { if (attribute != null) { return(attribute.Type); } if (IsCollectionType(field.FieldType)) { return(CommandLineArgumentType.MultipleUnique); } return(CommandLineArgumentType.AtMostOnce); }
private static bool ExplicitShortName(CommandLineArgumentAttribute attribute) { return(attribute != null && !attribute.DefaultShortName); }
private static string ShortName(CommandLineArgumentAttribute attribute, FieldInfo field) { return(!ExplicitShortName(attribute) ? LongName(attribute, field).Substring(0, 1) : attribute.ShortName); }
private static string Description(CommandLineArgumentAttribute attribute) { return(attribute != null ? attribute.Description : null); }
private static string LongName(CommandLineArgumentAttribute attribute, FieldInfo field) { return((attribute == null || attribute.DefaultLongName) ? field.Name : attribute.LongName); }