annotate MetroWpf/Stocks.Common/WebClientShim.cs @ 92:a4c165698579

repo.config added
author stevenhollidge <stevenhollidge@hotmail.com>
date Mon, 30 Apr 2012 10:58:45 +0100
parents 6109bc268b90
children
rev   line source
20
adminsh@apollo
parents:
diff changeset
1 using System.Net;
adminsh@apollo
parents:
diff changeset
2 using System;
adminsh@apollo
parents:
diff changeset
3
adminsh@apollo
parents:
diff changeset
4 namespace Stocks.Common
adminsh@apollo
parents:
diff changeset
5 {
adminsh@apollo
parents:
diff changeset
6 // Shim to wrap WebClient component to allow the shim to
adminsh@apollo
parents:
diff changeset
7 // be mocked or stubbed for unit tests.
adminsh@apollo
parents:
diff changeset
8 // Favours injection and composition over inheritence
adminsh@apollo
parents:
diff changeset
9 public class WebClientShim : IWebClientShim
adminsh@apollo
parents:
diff changeset
10 {
adminsh@apollo
parents:
diff changeset
11 private WebClient _webClient;
adminsh@apollo
parents:
diff changeset
12
adminsh@apollo
parents:
diff changeset
13 public WebClientShim(WebClient webClient)
adminsh@apollo
parents:
diff changeset
14 {
adminsh@apollo
parents:
diff changeset
15 _webClient = webClient;
adminsh@apollo
parents:
diff changeset
16 }
adminsh@apollo
parents:
diff changeset
17
adminsh@apollo
parents:
diff changeset
18 public string DownloadString(string address)
adminsh@apollo
parents:
diff changeset
19 {
adminsh@apollo
parents:
diff changeset
20 return _webClient.DownloadString(address).ToString();
adminsh@apollo
parents:
diff changeset
21 }
adminsh@apollo
parents:
diff changeset
22
adminsh@apollo
parents:
diff changeset
23 public void Dispose()
adminsh@apollo
parents:
diff changeset
24 {
adminsh@apollo
parents:
diff changeset
25 _webClient.Dispose();
adminsh@apollo
parents:
diff changeset
26 }
adminsh@apollo
parents:
diff changeset
27 }
adminsh@apollo
parents:
diff changeset
28 }