mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-19 16:06:35 +08:00
19 lines
539 B
C#
19 lines
539 B
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Reflection;
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
{
|
|
public static class EnumExtension
|
|
{
|
|
public static string GetDescription(this Enum value)
|
|
{
|
|
FieldInfo field = value.GetType().GetField(value.ToString());
|
|
DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
|
|
|
|
return attribute == null ? value.ToString() : attribute.Description;
|
|
}
|
|
|
|
}
|
|
}
|