using System;
using System.ComponentModel;
using System.Reflection;

namespace TsSFCDeivceClient.Model.DeviceWarrantyRequest
{
    public enum DeviceWarrantyRequestFormStatus
    {
        [Description("待维修")]
        AwaitingRepair,
        [Description("待审核")]
        AwaitingApproval,
        [Description("已完成")]
        BeComplate,
        [Description("全部")]
        All
    }

    public static class DeviceWarrantyRequestFormStatusEx
    {
        /// <summary>
        /// 获取枚举类型的描述
        /// </summary>
        /// <param name="enumeration"></param>
        /// <returns></returns>
        public static string ToDescription(this DeviceWarrantyRequestFormStatus 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();
        }
    }
}
