void FindObjectsAnd(Variable result, IEnumerable<FindObjectCondition> findObjectConditions) { var list = result.Value as IList; if (list != null) { var items = GetObjects(result.ObjectType); list.Clear(); bool allTrue; foreach (var item in items) { allTrue = true; var itemUid = GetObjectUid(item); foreach (var findObjectCondition in findObjectConditions) { var propertyValue = GetPropertyValue(findObjectCondition.Property, item); var conditionValue = GetValue(findObjectCondition.SourceArgument); var comparer = Compare(propertyValue, conditionValue, findObjectCondition.ConditionType); if (comparer == null || !comparer.Value) { allTrue = false; break; } } if (allTrue) result.AddToList(item); } } }
void FindObjectsOr(Variable result, IEnumerable<FindObjectCondition> findObjectConditions) { var list = result.Value as List<object>; if (list != null) { var items = GetObjects(result.ObjectType); list.Clear(); foreach (var item in items) { var itemUid = GetObjectUid(item); foreach (var findObjectCondition in findObjectConditions) { var propertyValue = GetPropertyValue(findObjectCondition.Property, item); var conditionValue = GetValue(findObjectCondition.SourceArgument); var comparer = Compare(propertyValue, conditionValue, findObjectCondition.ConditionType); if (comparer != null && comparer.Value) { result.AddToList(item); break; } } } } }