<summary>////Returns the description of the enumeration value///</summary>//<param name= "Value" > enumeration value </param> <returns> Specify enumeration value description </returns> public static string Getenumdescription (this enum value) {FieldInfo fi = value. GetType (). GetField (value. ToString ()); if (fi = = null) {return value. ToString (); } object[] attributes = fi. GetCustomAttributes (typeof (Enumdescriptionattribute), false); if (attributes = = NULL | | attributes. Length = = 0) {return value. ToString (); } else {string[] arr = ((Enumdescriptionattribute) attributes[0]). Description.split (new string[] {","}, Stringsplitoptions.none); return Appcommon.convertlanguage (arr); }}///<summary>//Returns all values, text, and descriptions in the type, based on enumeration type///</summary>// <param NAMe= "type" ></param>///<returns> returns three-column array, NO. 0 listed as description, 1th column value, 2nd Column text</returns> Pub Lic static list<enumoperation> getenumopt (type type) {list<enumoperation> ret = new List< ; Enumoperation> (); fieldinfo[] fields = type. GetFields (); for (int i = 1, count = fields. Length; I < count; i++) {Enumoperation eo = new enumoperation (); FieldInfo field = Fields[i]; enumeration value Eo.value = (int) enum.parse (type, field. Name); Enumeration name Eo.name = field. Name; Enumeration description Information object[] objs = field. GetCustomAttributes (typeof (Isip.assembly.EnumDescriptionAttribute), false); if (OBJS = = NULL | | objs. Length = = 0) {eo.desc = field. Name; } else {Isip.assembly.EnumDescripTionattribute da = (isip.assembly.EnumDescriptionAttribute) objs[0]; string[] arr = da. Description.split (new string[] {","}, Stringsplitoptions.none); Eo.desc = Appcommon.convertlanguage (arr); } ret. ADD (EO); } return ret; }[serializable] public class Enumoperation {public string name {get; set;} public string desc {get; set;} public int value {get; set;} Public dictionary<string, int[]> section {get; set;} }
The description of the returned enumeration value returns all values, literals, and descriptions in the type based on the enumeration type