ace/Source/ACE.Entity/Enum/AttributeExtensions.cs
gmriggs 5ff752e4b6
Fixing armor coverage in slots inventory (#1278)
* Fixing armor coverage in slots inventory

* Refactor

* cleaning up imports

* EquipMask -> ValidLocations for clarity

* update msg

* cleaning up werrors

* more cleanup + comments
2019-01-15 23:45:35 -05:00

13 lines
458 B
C#

namespace ACE.Entity.Enum
{
public static class AttributeExtensions
{
public static T GetAttributeOfType<T>(this System.Enum enumVal) where T : System.Attribute
{
var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
return (attributes.Length > 0) ? (T)attributes[0] : null;
}
}
}