Add support for deprecated values in field select options
This commit is contained in:
parent
3c17260c72
commit
d9786887f3
|
@ -123,7 +123,7 @@ namespace Sonarr.Http.ClientSchema
|
||||||
Placeholder = fieldAttribute.Placeholder
|
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())
|
if (fieldAttribute.SelectOptionsProviderAction.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
@ -172,11 +172,15 @@ namespace Sonarr.Http.ClientSchema
|
||||||
{
|
{
|
||||||
if (selectOptions.IsEnum)
|
if (selectOptions.IsEnum)
|
||||||
{
|
{
|
||||||
var options = selectOptions.GetFields().Where(v => v.IsStatic).Select(v =>
|
var options = selectOptions
|
||||||
|
.GetFields()
|
||||||
|
.Where(v => v.IsStatic && !v.GetCustomAttributes(false).OfType<ObsoleteAttribute>().Any())
|
||||||
|
.Select(v =>
|
||||||
{
|
{
|
||||||
var name = v.Name.Replace('_', ' ');
|
var name = v.Name.Replace('_', ' ');
|
||||||
var value = Convert.ToInt32(v.GetRawConstantValue());
|
var value = Convert.ToInt32(v.GetRawConstantValue());
|
||||||
var attrib = v.GetCustomAttribute<FieldOptionAttribute>();
|
var attrib = v.GetCustomAttribute<FieldOptionAttribute>();
|
||||||
|
|
||||||
if (attrib != null)
|
if (attrib != null)
|
||||||
{
|
{
|
||||||
return new SelectOption
|
return new SelectOption
|
||||||
|
@ -187,15 +191,13 @@ namespace Sonarr.Http.ClientSchema
|
||||||
Hint = attrib.Hint ?? $"({value})"
|
Hint = attrib.Hint ?? $"({value})"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return new SelectOption
|
return new SelectOption
|
||||||
{
|
{
|
||||||
Value = value,
|
Value = value,
|
||||||
Name = name,
|
Name = name,
|
||||||
Order = value
|
Order = value
|
||||||
};
|
};
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return options.OrderBy(o => o.Order).ToList();
|
return options.OrderBy(o => o.Order).ToList();
|
||||||
|
|
Loading…
Reference in New Issue