public string DownloadString(Uri url, TimeSpan timeout) { using (FactoryLease <WebClientEx> webClient = new FactoryLease <WebClientEx>(webClientFactory.CreateInnerWebClient(), webClientFactory)) { ConfigureWebClient(webClient.Obj, timeout); try { return(webClient.Obj.DownloadString(url)); } catch (WebException ex) { Log( true, "DownloadString (url='{0}') failed. Reason : {1}", url, ex); throw; } } }
public byte[] UploadData(Uri url, string method, byte[] data, TimeSpan timeout) { using (FactoryLease <WebClientEx> webClient = new FactoryLease <WebClientEx>(webClientFactory.CreateInnerWebClient(), webClientFactory)) { ConfigureWebClient(webClient.Obj, timeout); try { return(webClient.Obj.UploadData(url, method, data)); } catch (WebException ex) { Log( true, "UploadData (url='{0}') failed. Reason : {1}", url, ex); throw; } } }
public void DownloadFile(Uri url, TimeSpan timeout, string localPath) { using (FactoryLease <WebClientEx> webClient = new FactoryLease <WebClientEx>(webClientFactory.CreateInnerWebClient(), webClientFactory)) { ConfigureWebClient(webClient.Obj, timeout); try { fileSystem.EnsureDirectoryExists(Path.GetDirectoryName(localPath)); webClient.Obj.DownloadFile(url, localPath); } catch (WebException ex) { Log( true, "DownloadFile (url='{0}') failed. Reason : {1}", url, ex); throw; } } }