using System;
using System.Collections.Generic;
using System.Reflection;
namespace Velocity
{
publicstaticclass Util
{
publicstatic List<T> GetEnumValues<T>()
{
Type currentEnum = typeof(T);
List<T> resultSet = new List<T>();
if (currentEnum.IsEnum)
{
FieldInfo[] fields = currentEnum.GetFields(BindingFlags.Static | BindingFlags.Public);
foreach (FieldInfo field in fields)
resultSet.Add((T)field.GetValue(null));
}
elsethrownew ArgumentException("The argument must of type Enum or of a type derived from Enum", "T");
return resultSet;
}
}
}