Пример #1
0
        private void HandleWebExceptionError(WebException e)
        {
            var response = (HttpWebResponse)e.Response;

            if (!response.StatusCode.Equals(HttpStatusCode.OK))
            {
                ErrorHandler?.Invoke(e);
                HttpErrorHandler?.Invoke(response.StatusCode);
                switch (response.StatusCode)
                {
                case HttpStatusCode.BadRequest:
                    BadRequestErrorHandler?.Invoke();
                    break;

                case HttpStatusCode.InternalServerError:
                    InternalServerErrorHandler?.Invoke();
                    break;

                case HttpStatusCode.RequestTimeout:
                    TimeOutHandler?.Invoke();
                    break;

                case HttpStatusCode.NotFound:
                    NotFoundHandler?.Invoke();
                    break;

                case HttpStatusCode.Unauthorized:
                    UnauthorizeHandler?.Invoke();
                    break;
                }
            }

            RequestCompletedHandler?.Invoke();
        }
Пример #2
0
 // ctor
 public TimeOutContext(uint time, TimeOutHandler tHandler, object ctx)
 {
     timeValue = time;
     handler   = tHandler;
     context   = ctx;
 }