diff --git a/src/NzbDrone.Common/Extensions/EnumExtensions.cs b/src/NzbDrone.Common/Extensions/EnumExtensions.cs new file mode 100644 index 000000000..fcc550d99 --- /dev/null +++ b/src/NzbDrone.Common/Extensions/EnumExtensions.cs @@ -0,0 +1,17 @@ +using System; +using System.Linq; + +namespace NzbDrone.Common.Extensions +{ + public static class EnumExtensions + { + public static T GetAttribute(this Enum value) + where T : Attribute + { + var enumType = value.GetType(); + var name = Enum.GetName(enumType, value); + + return name == null ? null : enumType.GetField(name)?.GetCustomAttributes(false).OfType().SingleOrDefault(); + } + } +}