using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XYY.Data.Model.Standard.Tracking.Dto
{
    public class Trace_SupplementByCustomer
    {
        public DateTime ReceiveTime { get; set; }
        public string TrackingNumber { get; set; }
        public DateTime? TrackSupplementTime { get; set; }
        public string TrackSupplementText { get; set; }
        

    }
    public enum TrackSupplementTextEnum
    {
        [Description("Arrived GuangZhou")]
        邮局转运=1,
        //[Description("东莞, It is under customs clearance.")]
        //报关 = 2,
        //[Description("Item is ready for departure.")]
        //离开中国 = 3,
        //[Description("Item is being presented to customs.")]
        //落地 = 4,
        //[Description("Item is in transit to Post Office.")]
        //清关 = 5,
        //[Description("Arrived at Post Office.")]
        //交UPS = 6,
    }
    public static class EnumHelper
    {
        public static T GetEnumByDescription<T>(string description) where T : Enum
        {
            System.Reflection.FieldInfo[] fields = typeof(T).GetFields();
            foreach (System.Reflection.FieldInfo field in fields)
            {
                object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false);    //获取描述属性
                if (objs.Length > 0 && (objs[0] as DescriptionAttribute).Description == description)
                {
                    return (T)field.GetValue(null);
                }
            }
            throw new ArgumentException(string.Format("{0} 未能找到对应的枚举.", description), "Description");
        }
    }
}
