public Argument(CommandLineArgumentAttribute attribute, FieldInfo field)
            {
                this.field = field;

                longName  = GetLongName(attribute, field);
                shortName = GetShortName(attribute, field);
                valueType = GetValueType(field);
                flags     = GetFlags(attribute, field);

                if (attribute != null)
                {
                    isDefault   = attribute is DefaultCommandLineArgumentAttribute;
                    description = attribute.Description;
                    valueLabel  = attribute.ValueLabel;
                    synonyms    = attribute.Synonyms;
                }
                else
                {
                    synonyms = EmptyArray <string> .Instance;
                }

                if (IsCollection && !AllowMultiple)
                {
                    ThrowError(Resources.CommandLineArgumentParser_Argument_CollectionArgumentsMustAllowMultipleValues);
                }
                if (string.IsNullOrEmpty(longName))
                {
                    ThrowError(Resources.CommandLineArgumentParser_Argument_MissingLongName);
                }
                if (Unique && !IsCollection)
                {
                    ThrowError(Resources.CommandLineArgumentParser_Argument_InvalidUsageOfUniqueFlag);
                }
                if (!IsValidElementType(valueType))
                {
                    ThrowError(Resources.CommandLineArgumentParser_Argument_UnsupportedValueType);
                }
            }
 /// <summary>
 /// Indicates that this argument is the default argument.
 /// </summary>
 /// <param name="flags"> Specifies the error checking to be done on the argument.</param>
 public DefaultCommandLineArgumentAttribute(CommandLineArgumentFlags flags)
     : base(flags)
 {
 }
 /// <summary>
 /// Allows control of command line parsing.
 /// </summary>
 /// <param name="flags">Specifies the error checking to be done on the argument.</param>
 public CommandLineArgumentAttribute(CommandLineArgumentFlags flags)
 {
     this.flags = flags;
 }
 /// <summary>
 /// Allows control of command line parsing.
 /// </summary>
 /// <param name="flags">Specifies the error checking to be done on the argument.</param>
 public CommandLineArgumentAttribute(CommandLineArgumentFlags flags)
 {
     this.flags = flags;
 }
Esempio n. 5
0
 /// <summary>
 /// Indicates that this argument is the default argument.
 /// </summary>
 /// <param name="flags"> Specifies the error checking to be done on the argument.</param>
 public DefaultCommandLineArgumentAttribute(CommandLineArgumentFlags flags)
     : base(flags)
 {
 }
            public Argument(CommandLineArgumentAttribute attribute, FieldInfo field)
            {
                this.field = field;

                longName = GetLongName(attribute, field);
                shortName = GetShortName(attribute, field);
                valueType = GetValueType(field);
                flags = GetFlags(attribute, field);

                if (attribute != null)
                {
                    isDefault = attribute is DefaultCommandLineArgumentAttribute;
                    description = attribute.Description;
                    valueLabel = attribute.ValueLabel;
                    synonyms = attribute.Synonyms;
                }
                else
                {
                    synonyms = EmptyArray<string>.Instance;
                }

                if (IsCollection && !AllowMultiple)
                    ThrowError(Resources.CommandLineArgumentParser_Argument_CollectionArgumentsMustAllowMultipleValues);
                if (string.IsNullOrEmpty(longName))
                    ThrowError(Resources.CommandLineArgumentParser_Argument_MissingLongName);
                if (Unique && ! IsCollection)
                    ThrowError(Resources.CommandLineArgumentParser_Argument_InvalidUsageOfUniqueFlag);
                if (! IsValidElementType(valueType))
                    ThrowError(Resources.CommandLineArgumentParser_Argument_UnsupportedValueType);
            }