/// <summary> /// /// </summary> /// <param name="enumType"></param> /// <param name="tag"></param> /// <returns></returns> public static object GetEnumValueByTag(Type enumType, object tag) { IList <EnumDescription> source = DoGetFieldTexts(enumType); if (source == null) { return(null); } return(CollectionConverter.ConvertFirstSpecification <EnumDescription, object>(source, delegate(EnumDescription des) { return des.enumValue; }, delegate(EnumDescription des) { return des.tag.ToString() == tag.ToString(); })); }
/// <summary> /// /// </summary> /// <param name="enumValue"></param> /// <returns></returns> public static string GetFieldText(object enumValue) { IList <EnumDescription> source = DoGetFieldTexts(enumValue.GetType()); if (source == null) { return(null); } return(CollectionConverter.ConvertFirstSpecification <EnumDescription, string>(source, delegate(EnumDescription ed) { return ed.Description; }, delegate(EnumDescription ed) { return ed.enumValue.ToString() == enumValue.ToString(); })); }