2025-01-27 22:22:47 -05:00
|
|
|
|
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)
|
2025-01-27 22:30:22 -05:00
|
|
|
|
{
|
2025-01-27 22:22:47 -05:00
|
|
|
|
return enumValue.ToString();
|
2025-01-27 22:30:22 -05:00
|
|
|
|
}
|
2025-01-27 22:22:47 -05:00
|
|
|
|
|
|
|
|
|
if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)
|
|
|
|
|
{
|
|
|
|
|
return attribute.Description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return enumValue.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|