PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/V1/trunk/Source/StockTraderRI/StockRI.Tests.AcceptanceTests/TestInfrastructure/DataProvider/ModuleDataProviders/OrderDataProvider.cs

#
C# | 68 lines | 44 code | 8 blank | 16 comment | 2 complexity | 1e687a8d594e6f2aa6b1674d74c80125 MD5 | raw file
 1//===============================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation
 4//===============================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===============================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===============================================================================
17
18using System;
19using System.Data;
20using System.Collections.Generic;
21using StockTraderRI.AcceptanceTests.Helpers;
22using System.IO;
23using System.Globalization;
24
25
26namespace StockTraderRI.AcceptanceTests.TestInfrastructure
27{
28    public class OrderDataProvider : DataProviderBase<Order>
29    {
30        public OrderDataProvider()
31            : base()
32        { }
33
34        public override string GetDataFilePath()
35        {
36            return ConfigHandler.GetValue("OrderProcessingFile");
37        }
38
39        public override List<Order> GetData()
40        {
41            List<Order> order = new List<Order>();
42            string filepath = GetDataFilePath();
43
44            if (File.Exists(filepath))
45            {
46                DataSet ds = new DataSet();
47                ds.Locale = CultureInfo.CurrentCulture;
48                ds.ReadXml(filepath);
49                DataRow dr = null;
50
51
52                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
53                {
54                    dr = ds.Tables[0].Rows[i];
55                    order.Add(
56                        new Order(dr["TickerSymbol"].ToString(),
57                        decimal.Parse(dr["StopLimitPrice"].ToString(), CultureInfo.InvariantCulture),
58                        dr["OrderType"].ToString(),
59                        int.Parse(dr["Shares"].ToString(), CultureInfo.InvariantCulture),
60                        dr["TimeInForce"].ToString(),
61                        dr["TransactionType"].ToString())
62                        );
63                }
64            }
65            return order;
66        }
67    }
68}