| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System.Collections.Generic;
- namespace SKMC.Api.Process.Model
- {
- /// <summary>
- /// 条件匹配帮助类
- /// </summary>
- public class Cnds
- {
- public static bool Match(DioCnd dioCnd) => dioCnd.Match();
- public static bool Match(AxisCnd axisCnd) => axisCnd.Match();
- public static bool MatchAnd(List<DioCnd> dioCnds)
- {
- bool result = true;
- foreach (var dioCnd in dioCnds)
- {
- bool dioResult = dioCnd.Match();
- //log.Debug($"cnd [{dioCnd.Code}]: {dioResult}");
- result &= dioResult;
- }
- return result;
- }
- /// <summary>
- /// 满足其中一个DioCnd即可
- /// </summary>
- /// <param name="dioCnds"></param>
- /// <returns></returns>
- public static bool MatchOr(List<DioCnd> dioCnds)
- {
- bool result = false;
- foreach (var dioCnd in dioCnds)
- {
- bool dioResult = dioCnd.Match();
- //log.Debug($"cnd [{dioCnd.Code}]: {dioResult}");
- result |= dioResult;
- }
- return result;
- }
- /// <summary>
- /// 同时满足多个AxisCnd
- /// </summary>
- /// <param name="axisCnds"></param>
- /// <returns></returns>
- public static bool MatchAnd(List<AxisCnd> axisCnds)
- {
- bool result = true;
- foreach (var axisCnd in axisCnds)
- {
- result &= axisCnd.Match();
- }
- return result;
- }
- /// <summary>
- /// 满足一个AxisCnd即可
- /// </summary>
- /// <param name="axisCnds"></param>
- /// <returns></returns>
- public static bool MatchOr(List<AxisCnd> axisCnds)
- {
- bool result = false;
- foreach (var axisCnd in axisCnds)
- {
- result |= axisCnd.Match();
- }
- return result;
- }
- }
- }
|