Add project files.
This commit is contained in:
18
ConstructorAppUI/Helpers/EnumExtensions.cs
Normal file
18
ConstructorAppUI/Helpers/EnumExtensions.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user