コード例 #1
0
 private static string Description(CommandLineArgumentAttribute attribute)
 {
     if (attribute != null)
     {
         return(attribute.Description);
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
 private static CommandLineArgumentType Flags(CommandLineArgumentAttribute attribute, FieldInfo field)
 {
     if (attribute != null)
     {
         return(attribute.Type);
     }
     else if (IsCollectionType(field.FieldType))
     {
         return(CommandLineArgumentType.MultipleUnique);
     }
     else
     {
         return(CommandLineArgumentType.AtMostOnce);
     }
 }
コード例 #3
0
            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.");
            }
コード例 #4
0
 private static bool ExplicitShortName(CommandLineArgumentAttribute attribute)
 {
     return(attribute != null && !attribute.DefaultShortName);
 }
コード例 #5
0
 private static string ShortName(CommandLineArgumentAttribute attribute, FieldInfo field)
 {
     return(!ExplicitShortName(attribute) ? LongName(attribute, field).Substring(0, 1) : attribute.ShortName);
 }
コード例 #6
0
 private static string LongName(CommandLineArgumentAttribute attribute, FieldInfo field)
 {
     return((attribute == null || attribute.DefaultLongName) ? field.Name : attribute.LongName);
 }