CustomFormula.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. namespace FML.NATIVE
  2. {
  3. using Easychart.Finance;
  4. using Easychart.Finance.DataProvider;
  5. using System;
  6. using System.Collections;
  7. public class CustomFormula : FormulaBase
  8. {
  9. private ArrayList alFormulas;
  10. public CustomFormula()
  11. {
  12. this.alFormulas = new ArrayList();
  13. }
  14. public CustomFormula(string Name)
  15. {
  16. this.alFormulas = new ArrayList();
  17. base.Name = Name;
  18. }
  19. public void Add(double[] Data)
  20. {
  21. this.Add("", Data);
  22. }
  23. public void Add(string Name, double[] Data)
  24. {
  25. this.Add(Name, (double[]) null, Data);
  26. }
  27. public void Add(string Name, DateTime[] Date, double[] Data)
  28. {
  29. double[] date = new double[Date.Length];
  30. for (int i = 0; i < Date.Length; i++)
  31. {
  32. date[i] = Date[i].ToOADate();
  33. }
  34. this.Add(Name, date, Data);
  35. }
  36. public void Add(string Name, double[] Date, double[] Data)
  37. {
  38. this.alFormulas.Add(new CustomData(Name, Date, Data));
  39. }
  40. public override FormulaPackage Run(IDataProvider dp)
  41. {
  42. base.DataProvider = dp;
  43. FormulaData[] formulaDatas = new FormulaData[this.alFormulas.Count];
  44. for (int i = 0; i < formulaDatas.Length; i++)
  45. {
  46. CustomData data = (CustomData) this.alFormulas[i];
  47. if (data.Date != null)
  48. {
  49. formulaDatas[i] = base.AdjustDateTime(data.Date, data.Data);
  50. }
  51. else
  52. {
  53. formulaDatas[i] = data.Data;
  54. }
  55. formulaDatas[i].Name = data.Name;
  56. }
  57. return new FormulaPackage(formulaDatas, "");
  58. }
  59. }
  60. }