コード例 #1
0
 public static bool TryCreateFromResponseHeaders(WebHeaderCollection webHeaderCollection, out RequestFailureContext requestFailureContext)
 {
     if (webHeaderCollection == null)
     {
         throw new ArgumentNullException("webHeaderCollection");
     }
     return(RequestFailureContext.TryDeserialize(webHeaderCollection[RequestFailureContext.HeaderKey], out requestFailureContext));
 }
コード例 #2
0
 public static bool TryCreateFromResponse(HttpWebResponse cafeResponse, out RequestFailureContext requestFailureContext)
 {
     if (cafeResponse == null)
     {
         throw new ArgumentNullException("cafeResponse");
     }
     return(RequestFailureContext.TryCreateFromResponseHeaders(cafeResponse.Headers, out requestFailureContext));
 }
コード例 #3
0
        private void Deserialize(string serializedFailureContext)
        {
            string[] array = serializedFailureContext.Split(new char[]
            {
                ';'
            });
            int num = 0;

            if (array.Length >= 4)
            {
                string text = array[num++];
                RequestFailureContext.RequestFailurePoint failurePoint;
                if (!Enum.TryParse <RequestFailureContext.RequestFailurePoint>(text, out failurePoint))
                {
                    failurePoint = RequestFailureContext.RequestFailurePoint.Unrecognized;
                    this.UnrecognizedFailurePoint = text;
                }
                this.FailurePoint   = failurePoint;
                this.HttpStatusCode = RequestFailureContext.ConvertStringToInt(array[num++]);
                this.Error          = RequestFailureContext.ConvertStringFromBase64(array[num++]);
                this.Details        = RequestFailureContext.ConvertStringFromBase64(array[num++]);
                if (array.Length >= 6)
                {
                    HttpProxySubErrorCode value;
                    if (!Enum.TryParse <HttpProxySubErrorCode>(array[num++], out value))
                    {
                        this.HttpProxySubErrorCode = null;
                    }
                    else
                    {
                        this.HttpProxySubErrorCode = new HttpProxySubErrorCode?(value);
                    }
                    WebExceptionStatus value2;
                    if (!Enum.TryParse <WebExceptionStatus>(array[num++], out value2))
                    {
                        this.WebExceptionStatus = null;
                    }
                    else
                    {
                        this.WebExceptionStatus = new WebExceptionStatus?(value2);
                    }
                }
                if (array.Length >= 7)
                {
                    LiveIdAuthResult value3;
                    if (!Enum.TryParse <LiveIdAuthResult>(array[num++], out value3))
                    {
                        this.LiveIdAuthResult = null;
                        return;
                    }
                    this.LiveIdAuthResult = new LiveIdAuthResult?(value3);
                }
                return;
            }
            throw new FormatException("Expected a minimum of 4 parameters.");
        }
コード例 #4
0
 public static bool TryDeserialize(string headerValue, out RequestFailureContext requestFailureContext)
 {
     requestFailureContext = null;
     if (!string.IsNullOrEmpty(headerValue))
     {
         try
         {
             requestFailureContext = new RequestFailureContext(headerValue);
             return(true);
         }
         catch (FormatException)
         {
         }
         return(false);
     }
     return(false);
 }
コード例 #5
0
        public static bool TryCreateFromResponseHeaders(IDictionary <string, string> headerDictionary, out RequestFailureContext requestFailureContext)
        {
            if (headerDictionary == null)
            {
                throw new ArgumentNullException("headerDictionary");
            }
            requestFailureContext = null;
            string headerValue;

            return(headerDictionary.TryGetValue(RequestFailureContext.HeaderKey, out headerValue) && RequestFailureContext.TryDeserialize(headerValue, out requestFailureContext));
        }