annotate Stocks/Stocks.Common/WebClientShim.cs @ 19:09d18d6e5f40

airport work
author stevenh7776 stevenhollidge@hotmail.com
date Thu, 15 Mar 2012 06:59:15 +0000
parents 6e84a4c92378
children
rev   line source
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
1 using System.Net;
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
2 using System;
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
3
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
4 namespace Stocks.Common
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
5 {
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
6 // Shim to wrap WebClient component to allow the shim to
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
7 // be mocked or stubbed for unit tests.
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
8 // Favours injection and composition over inheritence
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
9 public class WebClientShim : IWebClientShim
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
10 {
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
11 private WebClient _webClient;
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
12
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
13 public WebClientShim(WebClient webClient)
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
14 {
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
15 _webClient = webClient;
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
16 }
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
17
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
18 public string DownloadString(string address)
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
19 {
4
57f20ba55884 Fix for webClientShim to use downloadString instead of downloadData
stevenh7776 stevenhollidge@hotmail.com
parents: 2
diff changeset
20 return _webClient.DownloadString(address).ToString();
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
21 }
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
22
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
23 public void Dispose()
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
24 {
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
25 _webClient.Dispose();
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
26 }
2
29ed98d659e9 Adding WebClientShim files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
27 }
6
c812bca7b1ac "Restore packages on build" enabled by Nuget 1.6
stevenh7776 stevenhollidge@hotmail.com
parents: 4
diff changeset
28 }