Files
aistudio-wpf-diagram/AIStudio.Wpf.DiagramDesigner/Helpers/EnumExtension.cs

19 lines
539 B
C#
Raw Normal View History

2021-07-23 09:42:22 +08:00
using System;
using System.ComponentModel;
using System.Reflection;
2022-10-28 22:45:39 +08:00
namespace AIStudio.Wpf.DiagramDesigner
2021-07-23 09:42:22 +08:00
{
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;
}
}
}