mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 22:06:33 +00:00
d320d6dd59
Made-with: Cursor
1.3 KiB
1.3 KiB
Module: Azaion.Common.Extensions.EnumExtensions
Purpose
Static utility class for extracting DescriptionAttribute values from enum members and retrieving default enum values.
Public Interface
| Method | Signature | Description |
|---|---|---|
GetDescriptions<T> |
static Dictionary<T, string> GetDescriptions<T>() where T : Enum |
Returns all enum values mapped to their [Description] text |
GetDescription |
static string GetDescription(this Enum enumValue) |
Extension: gets the [Description] of a single enum value |
GetDefaultValue<TEnum> |
static TEnum GetDefaultValue<TEnum>() where TEnum : struct |
Returns the [DefaultValue] attribute's value for an enum type |
Internal Logic
GetDescriptions<T>iterates all enum values viaEnum.GetValues, using a private helperGetEnumAttribto extract theDescriptionAttributevia reflection. Falls back to.ToString()when no attribute exists.GetEnumAttrib<T, TAttrib>fetches a custom attribute from an enum member'sFieldInfo.
Dependencies
System.ComponentModel.DescriptionAttribute,System.Reflection(BCL only)
Consumers
BusinessException(static constructor callsGetDescriptions<ExceptionEnum>())
Data Models
None.
Configuration
None.
External Integrations
None.
Security
None.
Tests
None.