示例#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>());
        }
示例#2
0
文件: WebHelper.cs 项目: Aecine/WFBot
        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");
            }
        }