/// <summary> /// Resolves <see cref="CommandOptionSchema"/>. /// </summary> internal static CommandOptionSchema?TryResolve(PropertyInfo property) { CommandOptionAttribute?attribute = property.GetCustomAttribute <CommandOptionAttribute>(); if (attribute is null) { return(null); } string name = attribute.HasAutoGeneratedName ? TextUtils.ToKebabCase(property.Name) : attribute.Name !; if (attribute.Converter is Type converterType && !converterType.Implements(typeof(IBindingConverter))) { throw AttributesExceptions.InvalidConverterType(converterType); } return(new CommandOptionSchema( property, name, attribute.ShortName, attribute.FallbackVariableName, attribute.IsRequired, attribute.Description, attribute.Converter )); }
/// <summary> /// Resolves <see cref="CommandParameterSchema"/>. /// </summary> public static CommandParameterSchema?TryResolve(PropertyInfo property) { CommandParameterAttribute?attribute = property.GetCustomAttribute <CommandParameterAttribute>(); if (attribute is null) { return(null); } string name = attribute.HasAutoGeneratedName ? TextUtils.ToKebabCase(property.Name) : attribute.Name !; if (attribute.Converter is Type converterType && !converterType.Implements(typeof(IBindingConverter))) { throw AttributesExceptions.InvalidConverterType(converterType); } return(new CommandParameterSchema( property, attribute.Order, name, attribute.Description, attribute.Converter )); }