rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
+20 -11
View File
@@ -3,18 +3,27 @@ using System.Reflection;
namespace adas_core.Domain.Utils;
/// <summary>
/// Provides static utility methods for working with <see cref="System.Enum"/> types.
/// </summary>
public static class EnumUtils
{
/// <summary>
/// Retrieves the human-readable description for an enumeration value by inspecting its <see cref="DescriptionAttribute"/>.
/// Falls back to the enum's string representation when no description attribute is defined on the member.
/// </summary>
/// <param name="value">The enumeration value whose description should be obtained.</param>
/// <returns>The description text from the <see cref="DescriptionAttribute"/> if present; otherwise, the string representation of the enum value.</returns>
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;
}
{
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;
}
}