38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
using System;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Reflection;
|
|||
|
|
|||
|
namespace TsSFCDeivceClient.Model.DeviceWarrantyRequest
|
|||
|
{
|
|||
|
public enum DeviceRunningStatus
|
|||
|
{
|
|||
|
[Description("全部")]
|
|||
|
All,
|
|||
|
[Description("停机")]
|
|||
|
Stop,
|
|||
|
[Description("非停机")]
|
|||
|
Running
|
|||
|
}
|
|||
|
|
|||
|
public static class DeviceRunningStatusEx
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 获取枚举类型的描述
|
|||
|
/// </summary>
|
|||
|
/// <param name="enumeration"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static string ToDescription(this DeviceRunningStatus enumeration)
|
|||
|
{
|
|||
|
Type type = enumeration.GetType();
|
|||
|
MemberInfo[] memInfo = type.GetMember(enumeration.ToString());
|
|||
|
if (null != memInfo && memInfo.Length > 0)
|
|||
|
{
|
|||
|
object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|||
|
if (null != attrs && attrs.Length > 0)
|
|||
|
return ((DescriptionAttribute)attrs[0]).Description;
|
|||
|
}
|
|||
|
return enumeration.ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|