Esempio n. 1
0
        public void TestDownloadToString()
        {
            const string Target =
                @"http://maps.googleapis.com/maps/api/geocode/xml?address=" +
                @"1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false";

            var client = new HttpDownloader(Target);
            var str = client.DownloadToString();
            Assert.IsTrue(str.Length == 1756);
            Assert.IsTrue(str.Contains("1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA"));
        }
Esempio n. 2
0
        // Вместо массива можно создать анонимный тип и применить dynamic.
        private void WorkingUnitWithArguments(object state)
        {
            var array = (object[])state;
            if (array.Length == 0)
                throw new ArgumentException(Resources.WorkingUnitWithAction_state_must_be_an_array, "state");

            var uri = array[0];
            var arg = array[1];

            var downloader = new HttpDownloader((string)uri, _options);
            downloader.DownloadProgress += (o, args) => _view.UpdateProgress(args.PercentComplete, (ProgressBar)arg);
            downloader.DownloadToFile(Path.GetTempFileName());
        }
Esempio n. 3
0
 public void TestDownloadFile()
 {
     var downloader = new HttpDownloader(Uri);
     downloader.DownloadProgress += DownloaderProgress;
     var tempFileName = Path.GetTempFileName();
     downloader.DownloadToFile(tempFileName);
     Assert.IsTrue(File.Exists(tempFileName));
     try
     {
         File.Delete(tempFileName);
     }
     catch
     {
     }
 }
Esempio n. 4
0
 private void WorkingUnit(object uri)
 {
     var downloader = new HttpDownloader((string)uri, _options);
     downloader.DownloadProgress += (o, args) => _view.UpdateProgress(args.PercentComplete);
     downloader.DownloadToFile(Path.GetTempFileName());
 }