Fix: Rename Generic.CL folder to flat structure, update csproj and references
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Generic.Services;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static string GetDisplayName(this Enum value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
|
||||
// Get the enum field name
|
||||
string name = value.ToString();
|
||||
|
||||
// Get the field info for the enum value
|
||||
FieldInfo? field = value.GetType().GetField(name);
|
||||
if (field == null)
|
||||
return name; // Not a defined enum value (e.g., flags combination)
|
||||
|
||||
// Check for the [Display] attribute
|
||||
DisplayAttribute? displayAttribute = field.GetCustomAttribute<DisplayAttribute>();
|
||||
return displayAttribute?.GetName() ?? name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user