Select type added for client schema

This commit is contained in:
Mark McDowall 2013-06-13 00:20:33 -07:00
commit ca334ef664
10 changed files with 76 additions and 5 deletions

View file

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.Annotations;
@ -34,6 +36,11 @@ namespace NzbDrone.Api.ClientSchema
field.Value = value;
}
if (fieldAttribute.Type == FieldType.Select)
{
field.SelectOptions = GetSelectOptions(fieldAttribute.SelectOptions);
}
result.Add(field);
}
}
@ -41,5 +48,13 @@ namespace NzbDrone.Api.ClientSchema
return result;
}
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() };
return options.OrderBy(o => o.Value).ToList();
}
}
}