private static string ShortName(ArgumentAttribute attribute, PropertyInfo property) { if (attribute is DefaultArgumentAttribute) return null; if (!ExplicitShortName(attribute)) return LongName(attribute, property).Substring(0, 1); return attribute.ShortName; }
private static string HelpText(ArgumentAttribute attribute, PropertyInfo property) { if (attribute == null) return null; else return attribute.HelpText; }
private static string LongName(ArgumentAttribute attribute, PropertyInfo property) { return (attribute == null || attribute.DefaultLongName) ? property.Name : attribute.LongName; }
private static bool HasHelpText(ArgumentAttribute attribute) { return (attribute != null && attribute.HasHelpText); }
private static ArgumentType Flags(ArgumentAttribute attribute, PropertyInfo property) { if (attribute != null) return attribute.Type; else if (IsCollectionType(property.PropertyType)) return ArgumentType.MultipleUnique; else return ArgumentType.AtMostOnce; }
private static bool ExplicitShortName(ArgumentAttribute attribute) { return (attribute != null && !attribute.DefaultShortName); }
private static object DefaultValue(ArgumentAttribute attribute, PropertyInfo property) { return (attribute == null || !attribute.HasDefaultValue) ? null : attribute.DefaultValue; }
public Argument(ArgumentAttribute attribute, PropertyInfo property, ErrorReporter reporter) { this.longName = Parser.LongName(attribute, property); this.explicitShortName = Parser.ExplicitShortName(attribute); this.shortName = Parser.ShortName(attribute, property); this.hasHelpText = Parser.HasHelpText(attribute); this.helpText = Parser.HelpText(attribute, property); this.defaultValue = Parser.DefaultValue(attribute, property); this.elementType = ElementType(property); this.flags = Flags(attribute, property); this.property = property; this.seenValue = false; this.reporter = reporter; this.isDefault = attribute != null && attribute is DefaultArgumentAttribute; if (IsCollection) { this.collectionValues = new ArrayList(); } }