private static TAttribute GetAttribute <TAttribute>(this SoundEffect value) where TAttribute : Attribute { var type = value.GetType(); var name = Enum.GetName(type, value); return(type.GetField(name) .GetCustomAttributes(false) .OfType <TAttribute>() .SingleOrDefault()); }