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