using System;
using System.Linq;
using System.Reflection;
namespace RGB.NET.Core.Extensions
{
public static class EnumExtensions
{
///
/// A generic extension method that aids in reflecting
/// and retrieving any attribute that is applied to an `Enum`.
///
public static TAttribute GetAttribute(this Enum enumValue)
where TAttribute : Attribute
{
return enumValue.GetType()
.GetMember(enumValue.ToString())
.First()
.GetCustomAttribute();
}
}
}