Example #1
0
        public Argument(object target, ParameterInfo mi)
            : base(target, mi)
        {
            _default = null;
            _required = true;
            _allArguments = Parameter.IsDefined(typeof (AllArgumentsAttribute), true);

            if (Parameter.DefaultValue != DBNull.Value)
            {
                _default = Parameter.DefaultValue;
                _required = false;
            }

            foreach (DefaultValueAttribute a in mi.GetCustomAttributes(typeof (DefaultValueAttribute), true))
            {
                _default = a.Value;
                _required = false;
            }

            foreach (ArgumentAttribute a in mi.GetCustomAttributes(typeof (ArgumentAttribute), true))
            {
                if (a.HasDefault)
                {
                    _required = false;
                    _default = a.DefaultValue;
                }
            }

            if (Visible && _description == mi.ToString())
            {
                if (IsFlag)
                {
                    if (Required)
                        _description = String.Format("Required flag can be \"/{0}\" or \"/{0}:false\".", base.DisplayName);
                    else
                        _description = String.Format("Optional flag of \"/{0}\" or \"/{0}:false\".", base.DisplayName);
                }
                else
                {
                    if (Required)
                        _description = String.Format("Specifies the required value for \"{0}\" of type {1}.", base.DisplayName,
                            UnderlyingType.Name);
                    else
                        _description = String.Format("Specifies an optional value for \"{0}\" of type {1}.", base.DisplayName,
                            UnderlyingType.Name);
                }
            }
        }