FFMpegCore/FFMpegCore.Extensions.Downloader/Extensions/EnumExtensions.cs
2025-01-27 22:30:22 -05:00

22 lines
577 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();
}
if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)
{
return attribute.Description;
}
return enumValue.ToString();
}
}