Skip to content

Instantly share code, notes, and snippets.

@christopherhouse
Created May 3, 2013 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherhouse/5513501 to your computer and use it in GitHub Desktop.
Save christopherhouse/5513501 to your computer and use it in GitHub Desktop.
namespace ThirteenDaysAWeek.TitleAttribute
{
public static class ReflectionExtensions
{
public static IEnumerable<T> GetCustomAttributes<T>(this Enum enumValue, bool inherit)
{
Type enumType = enumValue.GetType();
string enumValueName = Enum.GetName(enumType, enumValue);
MemberInfo enumMember = enumType.GetMember(enumValueName).First();
return enumMember.GetCustomAttributes(typeof (T), inherit)
.Cast<T>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment