using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace DHSoftware { public static class EnumHelper { public enum SelectPicType { [Description("训练图片")] train =0, [Description("测试图片")] test } public enum NetModel { [Description("目标检测")] training = 0, [Description("语义分割")] train_seg, [Description("模型导出")] emport, [Description("推理预测")] infernce } public static string GetEnumDescription(this Enum enumObj) { Type t = enumObj.GetType(); FieldInfo f = t.GetField(enumObj.ToString()); if (f == null) { return enumObj.ToString(); } DescriptionAttribute attr = f.GetCustomAttribute(); if (attr != null) { return attr.Description; } else { return enumObj.ToString(); } } } }