static void PopulateStockData() { Stream stream = GetResourceStream(dataPath); if (stream != null) { stockData = new List <OfflineStockData>(); XmlDocument doc = new XmlDocument(); doc.Load(stream); var nodes = doc.LastChild.SelectNodes("//StockData"); foreach (XmlNode node in nodes) { var data = new OfflineStockData() { CompanyID = Int32.Parse(node.Attributes["Name"].Value), Date = DateTime.Parse(node.Attributes["Date"].Value, CultureInfo.InvariantCulture), Price = Double.Parse(node.Attributes["Price"].Value, CultureInfo.InvariantCulture), OpenP = Double.Parse(node.Attributes["Open"].Value, CultureInfo.InvariantCulture), CloseP = Double.Parse(node.Attributes["Close"].Value, CultureInfo.InvariantCulture), HighP = Double.Parse(node.Attributes["High"].Value, CultureInfo.InvariantCulture), LowP = Double.Parse(node.Attributes["Low"].Value, CultureInfo.InvariantCulture), Volume = int.Parse(node.Attributes["Volume"].Value, CultureInfo.InvariantCulture), }; stockData.Add(data); } } stream.Close(); }
StockData GetServiceStockData(OfflineStockData data) { return(new StockData() { CompanyID = data.CompanyID, Date = data.Date, Price = Convert.ToDecimal(data.Price), OpenP = Convert.ToDecimal(data.OpenP), CloseP = Convert.ToDecimal(data.CloseP), HighP = Convert.ToDecimal(data.HighP), LowP = Convert.ToDecimal(data.LowP), Volumne = data.Volume }); }