Mercurial > silverbladetech
annotate MetroWpf/Stocks.Common/Factory.cs @ 65:5d0c5cc83a7a
Click event handler added
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Sun, 22 Apr 2012 14:21:33 +0100 |
parents | a8b50a087544 |
children |
rev | line source |
---|---|
24
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
20
diff
changeset
|
1 using Stocks.Common.Core; |
20 | 2 using Stocks.Common.Models; |
3 using System; | |
4 using Stocks.Common.Exceptions; | |
5 | |
6 namespace Stocks.Common | |
7 { | |
8 public class Factory | |
9 { | |
10 public static Price CreatePrice(string webPriceData) | |
11 { | |
12 if (string.IsNullOrEmpty(webPriceData)) | |
13 throw new InvalidWebPriceDataException(webPriceData); | |
14 | |
15 try | |
16 { | |
17 var symbol = webPriceData.Substring(1, webPriceData.IndexOf('"', 2) - 1); | |
18 | |
19 decimal price = decimal.Parse(webPriceData.Substring( | |
20 webPriceData.Length - webPriceData.Reverse().IndexOf(","))); | |
21 | |
22 return new Price() | |
23 { | |
24 Symbol = symbol, | |
25 PreviousPrice = price, | |
26 CurrentPrice = price | |
27 }; | |
28 } | |
29 catch (Exception e) | |
30 { | |
31 throw new InvalidWebPriceDataException(webPriceData, e); | |
32 } | |
33 } | |
34 } | |
35 } |