using DeviceRepair.Models.Attr;
using System;
using System.Reflection;
namespace DeviceRepair.Models
{
public static class ExtendFuncHelper
{
///
/// 获取枚举的描述文本信息
///
///
///
public static string Description(this System.Enum em)
{
Type type = em.GetType();
FieldInfo fd = type.GetField(em.ToString());
if (fd == null)
return string.Empty;
object[] attrs = fd.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);
string name = string.Empty;
foreach (EnumDescriptionAttribute attr in attrs)
{
name = attr.Desciption;
}
return name;
}
}
}