mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-02-18 11:02:31 +00:00
22 lines
646 B
C#
22 lines
646 B
C#
![]() |
using System.ComponentModel;
|
|||
|
|
|||
|
namespace FFMpegCore.Extensions.Downloader.Extensions;
|
|||
|
|
|||
|
internal static class EnumExtensions
|
|||
|
{
|
|||
|
public static string GetDescription(this Enum enumValue)
|
|||
|
{
|
|||
|
var field = enumValue.GetType().GetField(enumValue.ToString());
|
|||
|
if (field == null)
|
|||
|
return enumValue.ToString();
|
|||
|
|
|||
|
var attributes = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|||
|
if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)
|
|||
|
{
|
|||
|
return attribute.Description;
|
|||
|
}
|
|||
|
|
|||
|
return enumValue.ToString();
|
|||
|
}
|
|||
|
}
|