New: Better interface for creating custom formats

This commit is contained in:
ta264
2020-02-18 21:03:05 +00:00
committed by Qstick
parent a5bac30ef3
commit 241bf85f15
74 changed files with 2259 additions and 1090 deletions

View File

@@ -143,10 +143,21 @@ namespace Radarr.Http.ClientSchema
private static List<SelectOption> GetSelectOptions(Type selectOptions)
{
var options = from Enum e in Enum.GetValues(selectOptions)
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
if (selectOptions.IsEnum)
{
var options = from Enum e in Enum.GetValues(selectOptions)
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
return options.OrderBy(o => o.Value).ToList();
return options.OrderBy(o => o.Value).ToList();
}
if (typeof(ISelectOptionsConverter).IsAssignableFrom(selectOptions))
{
var converter = Activator.CreateInstance(selectOptions) as ISelectOptionsConverter;
return converter.GetSelectOptions();
}
throw new NotSupportedException();
}
private static Func<object, object> GetValueConverter(Type propertyType)