Esempio n. 1
0
        public static T UploadJson <T>(string url, string body, WebHeaderCollection header)
        {
            var wc = new WebClientEx2();

            wc.Headers = header;
            return(wc.UploadString(url, body).JsonDeserialize <T>());
        }
Esempio n. 2
0
        public static T DownloadJson <T>(string url, WebHeaderCollection header)
        {
            var sw = Stopwatch.StartNew();

            try
            {
                var wc = new WebClientEx2();
                wc.Headers = header;
                return(wc.DownloadString(url).JsonDeserialize <T>());
            }
            finally
            {
                Trace.WriteLine($"Download data completed: URL [{url}], Time [{sw.ElapsedMilliseconds}ms].", "Downloader");
            }
        }