Cnds.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections.Generic;
  2. namespace SKMC.Api.Process.Model
  3. {
  4. /// <summary>
  5. /// 条件匹配帮助类
  6. /// </summary>
  7. public class Cnds
  8. {
  9. public static bool Match(DioCnd dioCnd) => dioCnd.Match();
  10. public static bool Match(AxisCnd axisCnd) => axisCnd.Match();
  11. public static bool MatchAnd(List<DioCnd> dioCnds)
  12. {
  13. bool result = true;
  14. foreach (var dioCnd in dioCnds)
  15. {
  16. bool dioResult = dioCnd.Match();
  17. //log.Debug($"cnd [{dioCnd.Code}]: {dioResult}");
  18. result &= dioResult;
  19. }
  20. return result;
  21. }
  22. /// <summary>
  23. /// 满足其中一个DioCnd即可
  24. /// </summary>
  25. /// <param name="dioCnds"></param>
  26. /// <returns></returns>
  27. public static bool MatchOr(List<DioCnd> dioCnds)
  28. {
  29. bool result = false;
  30. foreach (var dioCnd in dioCnds)
  31. {
  32. bool dioResult = dioCnd.Match();
  33. //log.Debug($"cnd [{dioCnd.Code}]: {dioResult}");
  34. result |= dioResult;
  35. }
  36. return result;
  37. }
  38. /// <summary>
  39. /// 同时满足多个AxisCnd
  40. /// </summary>
  41. /// <param name="axisCnds"></param>
  42. /// <returns></returns>
  43. public static bool MatchAnd(List<AxisCnd> axisCnds)
  44. {
  45. bool result = true;
  46. foreach (var axisCnd in axisCnds)
  47. {
  48. result &= axisCnd.Match();
  49. }
  50. return result;
  51. }
  52. /// <summary>
  53. /// 满足一个AxisCnd即可
  54. /// </summary>
  55. /// <param name="axisCnds"></param>
  56. /// <returns></returns>
  57. public static bool MatchOr(List<AxisCnd> axisCnds)
  58. {
  59. bool result = false;
  60. foreach (var axisCnd in axisCnds)
  61. {
  62. result |= axisCnd.Match();
  63. }
  64. return result;
  65. }
  66. }
  67. }