Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace adas_core.Domain.Utils;
|
||||
|
||||
public static class EnumUtils
|
||||
{
|
||||
public static string GetDescription(Enum value)
|
||||
{
|
||||
var enumMember = value.GetType().GetMember(value.ToString()).FirstOrDefault();
|
||||
var descriptionAttribute =
|
||||
enumMember == null
|
||||
? null
|
||||
: enumMember.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute;
|
||||
return
|
||||
descriptionAttribute == null
|
||||
? value.ToString()
|
||||
: descriptionAttribute.Description;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user