hallo
This commit is contained in:
1 parent
9c8fb9b205
commit
bb13759af4
288 files changed
+102393
No files matched your search
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LEA.Extensions;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static string GetDisplayName(this Enum value)
|
||||
{
|
||||
var memberInfo = value.GetType().GetMember(value.ToString()).FirstOrDefault();
|
||||
var displayAttribute = memberInfo?.GetCustomAttribute<DisplayAttribute>();
|
||||
return displayAttribute?.GetName() ?? value.ToString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user