コード例 #1
0
 public CommandArgument(
     Type parameterType, ParameterKind parameterKind, PropertyInfo property, string?description,
     TypeConverterAttribute?converter, DefaultValueAttribute?defaultValue,
     CommandArgumentAttribute argument, IEnumerable <ParameterValidationAttribute> validators)
     : base(parameterType, parameterKind, property, description, converter, defaultValue,
            null, validators, argument.IsRequired)
 {
     Value    = argument.ValueName;
     Position = argument.Position;
 }
コード例 #2
0
        private static CommandArgument BuildArgumentParameter(PropertyInfo property, CommandArgumentAttribute attribute)
        {
            var description  = property.GetCustomAttribute <DescriptionAttribute>();
            var converter    = property.GetCustomAttribute <TypeConverterAttribute>();
            var defaultValue = property.GetCustomAttribute <DefaultValueAttribute>();
            var validators   = property.GetCustomAttributes <ParameterValidationAttribute>(true);

            var kind = GetParameterKind(property.PropertyType);

            return(new CommandArgument(
                       property.PropertyType, kind, property,
                       description?.Description, converter,
                       defaultValue, attribute, validators));
        }