using YG.Lib; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; namespace YGUV.Lib { public static class LibEnum { /// /// 根据枚举的值获取枚举名称 /// /// 枚举类型 /// 枚举的值 /// public static string GetEnumName(this int status) { return Enum.GetName(typeof(T), status); } /// /// 获取枚举名称集合 /// /// /// public static string[] GetNamesArr() { return Enum.GetNames(typeof(T)); } /// /// 将枚举转换成字典集合 /// /// 枚举类型 /// public static Dictionary getEnumDic() { Dictionary resultList = new Dictionary(); Type type = typeof(T); var strList = GetNamesArr().ToList(); foreach (string key in strList) { string val = Enum.Format(type, Enum.Parse(type, key), "d"); resultList.Add(key, int.Parse(val)); } return resultList; } /// /// 将枚举转换成字典 /// /// /// public static Dictionary GetDic() { Dictionary dic = new Dictionary(); Type t = typeof(TEnum); var arr = Enum.GetValues(t); foreach (var item in arr) { dic.Add(item.ToString(), (int)item); } return dic; } } public enum ageinRunType { /// /// 准备 /// Start, /// /// 执行中 /// Runing, /// /// 结束 /// End, } /// /// 测试项目类型 /// public enum ageingType { /// /// 点灯 /// Led, /// /// 电流 /// Elect, /// /// 命令 /// Set } }