Mercurial > silverbladetech
view Stocks/Stocks.Common/Factory.cs @ 16:2395908fa45b
Getting there... 1.20am at BKK airport.
MainWindow and Menu now have VMs, Login form is displayed first
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Wed, 14 Mar 2012 01:23:18 +0700 |
parents | e5d46bb6cdb0 |
children |
line wrap: on
line source
using NLog; using Stocks.Common.Core; using Stocks.Common.Models; using System; using Stocks.Common.Exceptions; namespace Stocks.Common { public class Factory { public static Price CreatePrice(string webPriceData) { if (string.IsNullOrEmpty(webPriceData)) throw new InvalidWebPriceDataException(webPriceData); try { var symbol = webPriceData.Substring(1, webPriceData.IndexOf('"', 2) - 1); decimal price = decimal.Parse(webPriceData.Substring( webPriceData.Length - webPriceData.Reverse().IndexOf(","))); return new Price() { Symbol = symbol, PreviousPrice = price, CurrentPrice = price }; } catch (Exception e) { throw new InvalidWebPriceDataException(webPriceData, e); } } } }