Enum constraint for enum dropdown.

This commit is contained in:
Huo Yaoyuan
2019-12-07 19:56:56 +08:00
parent 40a5c1fd96
commit c3518a2b94
7 changed files with 26 additions and 21 deletions

View File

@ -6,12 +6,10 @@ using System;
namespace osu.Game.Graphics.UserInterface
{
public class OsuEnumDropdown<T> : OsuDropdown<T>
where T : struct, Enum
{
public OsuEnumDropdown()
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument");
Items = (T[])Enum.GetValues(typeof(T));
}
}