예제 #1
0
        private static WebOperation CreateWebOperation(WebRequest webRequest)
        {
            var fileWebRequest = webRequest as FileWebRequest;
             if (fileWebRequest != null)
             {
            return new FileWebOperation(new FileWebRequestAdapter(fileWebRequest));
             }

             var httpWebRequest = webRequest as HttpWebRequest;
             if (httpWebRequest != null)
             {
            return new HttpWebOperation(new WebRequestAdapter(httpWebRequest));
             }

             var ftpWebRequest = webRequest as FtpWebRequest;
             if (ftpWebRequest != null)
             {
            return new FtpWebOperation(new FtpWebRequestAdapter(ftpWebRequest));
             }

             throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
            "Web Request Type '{0}' is not valid.", webRequest.GetType()));
        }
예제 #2
0
파일: PclExport.Sl5.cs 프로젝트: vebin/soa
 private static bool IsBrowserHttp(WebRequest req)
 {
     return req.GetType().Name == "BrowserHttpWebRequest";
 }
예제 #3
0
 internal RestRequest(WebRequest newRequest, IRequest oldRequest)
 {
     //Probably really slow, but makes sure we get the same 
     foreach(var property in oldRequest.GetType().GetProperties())
     {
         //Make sure property exists in new request in case they are different
         var propExists = newRequest.GetType().GetProperties().Contains(property);
         if (propExists)
         {
             if (property.Name != "RequestUri")
             {
                 property.SetValue(newRequest, property.GetValue(oldRequest));
             }
         }
     }
     _baseRequest = newRequest;
 }
 public void HandleErrorResponse(WebException exception, RequestError error, WebRequest request)
 {
     Utilities.ThrowIfNull(request, "request");
     if (!(request is HttpWebRequest))
     {
         throw new InvalidCastException(string.Concat("Expected a HttpWebRequest, but got a ", request.GetType(), " instead."));
     }
     var tClient = this.tokenProvider;
     TimeSpan? nullable = null;
     tClient.RefreshToken(this.State, nullable);
     this.ApplyAuthenticationToRequest((HttpWebRequest)request);
 }