2024-06-20 17:54:27 -05:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
2024-08-04 17:53:19 -05:00
|
|
|
|
namespace LANCommander.Launcher.Extensions
|
2024-06-20 17:54:27 -05:00
|
|
|
|
{
|
|
|
|
|
|
public static class EnumExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string GetDisplayName(this Enum value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value
|
|
|
|
|
|
.GetType()
|
|
|
|
|
|
.GetMember(value.ToString())
|
|
|
|
|
|
.First()
|
|
|
|
|
|
.GetCustomAttribute<DisplayAttribute>()?
|
|
|
|
|
|
.GetName() ?? value.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|