Beispiel #1
0
        /// <summary>
        /// </summary>
        /// <param name="status"></param>
        /// <param name="msg"></param>
        public MessageModel(HttpStatusEnum status, string msg = null)
        {
            Status = status;
            var msgPrefix = status.GetDescription(); //状态码信息

            Msg = string.IsNullOrWhiteSpace(msg) ? msgPrefix : $"{msgPrefix} {msg}";
        }
Beispiel #2
0
        private HttpStatusCode[] GetHttpStatusSeedData(DateTime dateTimeNow)
        {
            int Key                = 1;
            var ResultList         = new List <HttpStatusCode>();
            var HttpStatusCodeList = Enum.GetValues(typeof(System.Net.HttpStatusCode)).Cast <System.Net.HttpStatusCode>();

            // HttpStatusCode enum uses multiple integer values for the same value, e.g.
            // System.Net.HttpStatusCode uses these:
            // Ambiguous = 300,
            // MultipleChoices = 300,
            // Moved = 301,
            // MovedPermanently = 301,
            // Redirect = 302
            // Found = 302
            // RedirectMethod = 303
            // SeeOther = 303
            // RedirectKeepVerb = 307
            // TemporaryRedirect = 307
            //So here we filter them out with HttpStatusCodeList.Distinct()
            foreach (System.Net.HttpStatusCode HttpStatusEnum in HttpStatusCodeList.Distinct())
            {
                ResultList.Add(new HttpStatusCode()
                {
                    Id      = Key,
                    Code    = HttpStatusEnum.ToString(),
                    Number  = HttpStatusEnum,
                    Created = dateTimeNow,
                    Updated = dateTimeNow
                });
                Key++;
            }
            return(ResultList.ToArray());
        }