|
|
|
@ -107,7 +107,7 @@ namespace Readarr.Http.ClientSchema
|
|
|
|
|
Placeholder = fieldAttribute.Placeholder
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (fieldAttribute.Type == FieldType.Select || fieldAttribute.Type == FieldType.TagSelect)
|
|
|
|
|
if (fieldAttribute.Type is FieldType.Select or FieldType.TagSelect)
|
|
|
|
|
{
|
|
|
|
|
if (fieldAttribute.SelectOptionsProviderAction.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
@ -154,11 +154,17 @@ namespace Readarr.Http.ClientSchema
|
|
|
|
|
|
|
|
|
|
private static List<SelectOption> GetSelectOptions(Type selectOptions)
|
|
|
|
|
{
|
|
|
|
|
var options = selectOptions.GetFields().Where(v => v.IsStatic).Select(v =>
|
|
|
|
|
if (selectOptions.IsEnum)
|
|
|
|
|
{
|
|
|
|
|
var options = selectOptions
|
|
|
|
|
.GetFields()
|
|
|
|
|
.Where(v => v.IsStatic && !v.GetCustomAttributes(false).OfType<ObsoleteAttribute>().Any())
|
|
|
|
|
.Select(v =>
|
|
|
|
|
{
|
|
|
|
|
var name = v.Name.Replace('_', ' ');
|
|
|
|
|
var value = Convert.ToInt32(v.GetRawConstantValue());
|
|
|
|
|
var attrib = v.GetCustomAttribute<FieldOptionAttribute>();
|
|
|
|
|
|
|
|
|
|
if (attrib != null)
|
|
|
|
|
{
|
|
|
|
|
return new SelectOption
|
|
|
|
@ -169,20 +175,21 @@ namespace Readarr.Http.ClientSchema
|
|
|
|
|
Hint = attrib.Hint ?? $"({value})"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return new SelectOption
|
|
|
|
|
{
|
|
|
|
|
Value = value,
|
|
|
|
|
Name = name,
|
|
|
|
|
Order = value
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return options.OrderBy(o => o.Order).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Func<object, object> GetValueConverter(Type propertyType)
|
|
|
|
|
{
|
|
|
|
|
if (propertyType == typeof(int))
|
|
|
|
|