Mercurial > silverbladetech
annotate MetroWpf/Stocks.Common/Factory.cs @ 33:f3a0641c1586
bat files added to Messaging solution
author | adminsh@apollo |
---|---|
date | Thu, 22 Mar 2012 08:11:42 +0000 |
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 } |