mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
16 lines
484 B
C#
16 lines
484 B
C#
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace StableDiffusion.NET;
|
|
|
|
internal static class EnumExtension
|
|
{
|
|
public static string GetDescription(this Enum value)
|
|
{
|
|
DescriptionAttribute[]? attributes = (DescriptionAttribute[]?)value.GetType().GetField(value.ToString())?.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
return attributes?.Length > 0
|
|
? attributes[0].Description
|
|
: value.ToString();
|
|
}
|
|
} |