public CommandArgumentDescriptor(Type argumentType, string name, int order, string description, CoconaDefaultValue defaultValue, IReadOnlyList <Attribute> parameterAttributes) { ArgumentType = argumentType ?? throw new ArgumentNullException(nameof(argumentType)); Name = name ?? throw new ArgumentNullException(nameof(name)); Order = order; Description = description ?? throw new ArgumentNullException(nameof(description)); DefaultValue = defaultValue; ParameterAttributes = parameterAttributes; }
public CommandOptionDescriptor(Type optionType, string name, IReadOnlyList <char> shortName, string description, CoconaDefaultValue defaultValue, string?valueName, CommandOptionFlags flags, IReadOnlyList <Attribute> parameterAttributes) { OptionType = optionType ?? throw new ArgumentNullException(nameof(optionType)); Name = name ?? throw new ArgumentNullException(nameof(name)); ShortName = shortName ?? throw new ArgumentNullException(nameof(shortName)); Description = description ?? throw new ArgumentNullException(nameof(description)); DefaultValue = defaultValue; ValueName = valueName ?? OptionType.Name; Flags = flags; ParameterAttributes = parameterAttributes; if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentException("A name of the command option must not be empty.", nameof(name)); } if (defaultValue.HasValue && defaultValue.Value != null && defaultValue.Value.GetType() != optionType) { throw new ArgumentException($"The type of default value is not compatible with type of option.: OptionType={optionType.FullName}; ValueType={defaultValue.Value.GetType().FullName}"); } }