internal IEnumerable<string> GetEnablingConditionDescriptions(InterpretationContext c, IComparable/*?*/ thisArg, IComparable[]/*?*/ arguments, bool returnFailures) { foreach (Predicate pred in predicates) { c.SetAsActive(); try { bool holds = pred.Holds(thisArg, arguments); if ((returnFailures && !holds) || (!returnFailures && holds)) foreach (string s in pred.description) yield return s; } finally { c.ClearAsActive(); } } }
//static private bool ContainsAnyValue(object/*?*/[] arguments) //{ // for (int i = 0; i < arguments.Length; i++) // { // if (arguments[i] == Any.Value) return true; // } // return false; //} internal bool Holds(InterpretationContext c, IComparable/*?*/ thisArg, IComparable[]/*?*/ arguments) { c.SetAsActive(); try { //check each predicate foreach (Predicate pred in predicates) if (!pred.Holds(thisArg, arguments)) return false; return true; } finally { c.ClearAsActive(); } }
internal bool Holds(InterpretationContext c, Set<IComparable> domain) { c.SetAsActive(); try { //check each predicate foreach (Predicate pred in predicates) { if (pred.isStatic) { if (!((bool)pred.method.Invoke(null, new object[0]))) return false; } else { // if instance-based, check predicate for each instance in domain foreach (IComparable obj in domain) { if (!((bool)pred.method.Invoke(obj, new object[0]))) return false; } } } return true; } finally { c.ClearAsActive(); } }