Strategy.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WebAPIBase.NetCore.BusinessCore
  8. {
  9. public class Strategy
  10. {
  11. private ArrayList parameters = new ArrayList();
  12. private object m_Name;
  13. private string m_RelationFieldName;
  14. private StrategyType m_Type;
  15. public object Name => m_Name;
  16. public StrategyType Type
  17. {
  18. get
  19. {
  20. return m_Type;
  21. }
  22. set
  23. {
  24. m_Type = value;
  25. }
  26. }
  27. public string RelationFieldName
  28. {
  29. get
  30. {
  31. return m_RelationFieldName;
  32. }
  33. set
  34. {
  35. m_RelationFieldName = value;
  36. }
  37. }
  38. public Strategy(object name)
  39. {
  40. m_Name = name;
  41. m_Type = StrategyType.StringEqual;
  42. m_RelationFieldName = "";
  43. }
  44. public Strategy(object name, ArrayList pas)
  45. {
  46. m_Name = name;
  47. m_Type = StrategyType.StringEqual;
  48. m_RelationFieldName = "";
  49. parameters = pas;
  50. }
  51. public Strategy(object name, string param0)
  52. {
  53. m_Name = name;
  54. m_Type = StrategyType.StringEqual;
  55. m_RelationFieldName = "";
  56. parameters.Add(param0);
  57. }
  58. public Strategy(object name, string param0, string param1)
  59. {
  60. m_Name = name;
  61. m_Type = StrategyType.StringEqual;
  62. m_RelationFieldName = "";
  63. parameters.Add(param0);
  64. parameters.Add(param1);
  65. }
  66. public Strategy(object name, StrategyType type, string relationFieldName)
  67. {
  68. m_Name = name;
  69. m_Type = type;
  70. m_RelationFieldName = relationFieldName;
  71. }
  72. public Strategy(object name, StrategyType type, string relationFieldName, string param0)
  73. {
  74. m_Name = name;
  75. m_Type = type;
  76. m_RelationFieldName = relationFieldName;
  77. parameters.Add(param0);
  78. }
  79. public Strategy(object name, StrategyType type, string relationFieldName, ArrayList pas)
  80. {
  81. m_Name = name;
  82. m_Type = type;
  83. m_RelationFieldName = relationFieldName;
  84. parameters = pas;
  85. }
  86. public virtual void AddParameter(string parameterString)
  87. {
  88. parameters.Add(parameterString);
  89. }
  90. public virtual string GetParameter(int index)
  91. {
  92. if (index < 0 || index > parameters.Count)
  93. {
  94. throw new ApplicationException("索引越界");
  95. }
  96. if (Type == StrategyType.StringIn || Type == StrategyType.Other || Type == StrategyType.StringRange || Type == StrategyType.NumberIn)
  97. {
  98. return (string)parameters[index];
  99. }
  100. return (string)parameters[index];
  101. }
  102. public static string ReplaceSingleQuote(string s)
  103. {
  104. return s.Replace("'", "''");
  105. }
  106. public virtual void SetParameter(int index, string param)
  107. {
  108. parameters[index] = param;
  109. }
  110. public int GetParameterCount()
  111. {
  112. return parameters.Count;
  113. }
  114. public IEnumerator GetParameterEnumerator()
  115. {
  116. return parameters.GetEnumerator();
  117. }
  118. }
  119. }