19 lines
488 B
C#
19 lines
488 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Reflection;
|
|
|
|
namespace ConstructorAppUI.Helpers
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static string GetDisplayName(this Enum enumValue)
|
|
{
|
|
return enumValue
|
|
.GetType()
|
|
.GetMember(enumValue.ToString())
|
|
.First()
|
|
.GetCustomAttribute<DisplayAttribute>()?
|
|
.GetName() ?? enumValue.ToString();
|
|
}
|
|
}
|
|
}
|