You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
458 B
18 lines
458 B
using System;
|
|
using System.Linq;
|
|
|
|
namespace NzbDrone.Common.Extensions
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static T GetAttribute<T>(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<T>().SingleOrDefault();
|
|
}
|
|
}
|
|
}
|