예제 #1
0
        public RespDataBase(HttpResponseCode code)
        {
            this.Code = ((int)code).ToString();
            var filed = code.GetType().GetField(code.ToString());

            this.Message = ((DescriptionAttribute)filed.GetCustomAttributes(typeof(DescriptionAttribute), true).First()).Description;
        }
예제 #2
0
 public static string GetDescription(this HttpResponseCode val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }