public CommandArgument( Type parameterType, ParameterKind parameterKind, PropertyInfo property, string description, TypeConverterAttribute converter, CommandArgumentAttribute argument, IEnumerable <ParameterValidationAttribute> validators) : base(parameterType, parameterKind, property, description, converter, validators, argument.IsRequired) { Value = argument.ValueName; Position = argument.Position; }
public CommandArgument( Type parameterType, ParameterKind parameterKind, PropertyInfo property, string description, TypeConverterAttribute converter, CommandArgumentAttribute argument) : base(parameterType, parameterKind, property, description, converter, argument.IsRequired) { Value = argument.Value; Position = argument.Position; }
public void Should_Parse_Valid_Options(string template, bool required) { // Given, When var result = new CommandArgumentAttribute(0, template); // Then result.ValueName.ShouldBe("FOO"); result.IsRequired.ShouldBe(required); }
private static CommandArgument BuildArgumentParameter(PropertyInfo property, CommandArgumentAttribute attribute) { var description = property.GetCustomAttribute <DescriptionAttribute>(); var converter = property.GetCustomAttribute <TypeConverterAttribute>(); var validators = property.GetCustomAttributes <ParameterValidationAttribute>(true); var kind = GetParameterKind(property.PropertyType); return(new CommandArgument(property.PropertyType, kind, property, description?.Description, converter, attribute, validators)); }
public CommandArgument( Type parameterType, ParameterKind parameterKind, PropertyInfo property, string?description, TypeConverterAttribute?converter, DefaultValueAttribute?defaultValue, CommandArgumentAttribute argument, ParameterValueProviderAttribute?valueProvider, IEnumerable <ParameterValidationAttribute> validators) : base(parameterType, parameterKind, property, description, converter, defaultValue, null, valueProvider, validators, argument.IsRequired, false) { Value = argument.ValueName; Position = argument.Position; }
private static CommandArgument BuildArgumentParameter(PropertyInfo property, CommandArgumentAttribute attribute) { var description = property.GetCustomAttribute <DescriptionAttribute>(); var converter = property.GetCustomAttribute <TypeConverterAttribute>(); var kind = property.PropertyType == typeof(bool) ? ParameterKind.Flag : ParameterKind.Single; return(new CommandArgument(property.PropertyType, kind, property, description?.Description, converter, attribute)); }
public PropertyAttribute(PropertyInfo propertyInfo, CommandArgumentAttribute attribute) { PropertyInfo = propertyInfo; Attribute = attribute; }
private Argument ArgumentFromAttribute(Type commandType, PropertyInfo argumentProperty, CommandArgumentAttribute attribute) { var argument = new Argument(attribute.Name, attribute.Optional); if (attribute.Optional) { argument.SetDefault(attribute.DefaultValue); } return(argument); }