Mercurial > silverbladetech
annotate MetroWpf/Stocks.Common/ConfigurationService.cs @ 43:aef06698d9e2 Test
Added the library tests
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Wed, 04 Apr 2012 19:20:20 +0100 |
parents | dfc81f8bb838 |
children |
rev | line source |
---|---|
20 | 1 using System; |
2 using System.Collections.Generic; | |
3 using Stocks.Common; | |
4 using Stocks.Common.Core; | |
5 using Stocks.Common.Models; | |
6 using Newtonsoft.Json; | |
7 | |
8 namespace Stocks.Common | |
9 { | |
10 public class ConfigurationService : IConfigurationService | |
11 { | |
12 private string jsonFilename; | |
13 private string serviceUrlPrefix = "http://finance.yahoo.com/d/quotes.csv?s="; | |
14 private string serviceUrlSuffix = "&f=snl1"; | |
15 | |
16 public ConfigurationService(string filename) | |
17 { | |
18 jsonFilename = filename; | |
19 } | |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
20
diff
changeset
|
20 |
20 | 21 public List<Company> GetCompanies() |
22 { | |
23 return new FileSerializer().DeserializeJson<Company>(jsonFilename); | |
24 } | |
25 | |
26 public string GetServiceUrl(string symbolCsv) | |
27 { | |
28 if (string.IsNullOrEmpty(symbolCsv)) | |
29 throw new ArgumentException(); | |
30 | |
31 return string.Concat(serviceUrlPrefix, symbolCsv, serviceUrlSuffix); | |
32 } | |
33 | |
34 public string GetServiceUrl(string[] symbols) | |
35 { | |
36 if (symbols == null || symbols.Length == 0) | |
37 throw new ArgumentException(); | |
38 | |
39 var symbolCsv = string.Join(",", symbols); | |
40 return GetServiceUrl(symbolCsv); | |
41 } | |
42 } | |
43 } |