PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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. using System;
  18. using System.Data;
  19. using System.Collections.Generic;
  20. using StockTraderRI.AcceptanceTests.Helpers;
  21. using System.IO;
  22. using System.Globalization;
  23. namespace StockTraderRI.AcceptanceTests.TestInfrastructure
  24. {
  25. public class OrderDataProvider : DataProviderBase<Order>
  26. {
  27. public OrderDataProvider()
  28. : base()
  29. { }
  30. public override string GetDataFilePath()
  31. {
  32. return ConfigHandler.GetValue("OrderProcessingFile");
  33. }
  34. public override List<Order> GetData()
  35. {
  36. List<Order> order = new List<Order>();
  37. string filepath = GetDataFilePath();
  38. if (File.Exists(filepath))
  39. {
  40. DataSet ds = new DataSet();
  41. ds.Locale = CultureInfo.CurrentCulture;
  42. ds.ReadXml(filepath);
  43. DataRow dr = null;
  44. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  45. {
  46. dr = ds.Tables[0].Rows[i];
  47. order.Add(
  48. new Order(dr["TickerSymbol"].ToString(),
  49. decimal.Parse(dr["StopLimitPrice"].ToString(), CultureInfo.InvariantCulture),
  50. dr["OrderType"].ToString(),
  51. int.Parse(dr["Shares"].ToString(), CultureInfo.InvariantCulture),
  52. dr["TimeInForce"].ToString(),
  53. dr["TransactionType"].ToString())
  54. );
  55. }
  56. }
  57. return order;
  58. }
  59. }
  60. }