18 lines
471 B
C#
18 lines
471 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Reflection;
|
|
|
|
namespace LANCommander.Extensions
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static string GetDisplayName(this Enum value)
|
|
{
|
|
return value
|
|
.GetType()
|
|
.GetMember(value.ToString())
|
|
.First()
|
|
.GetCustomAttribute<DisplayAttribute>()?
|
|
.GetName() ?? value.ToString();
|
|
}
|
|
}
|
|
}
|