/// <summary> /// Computes the specified computable object. /// </summary> /// <param name="computableObject">The computable object.</param> /// <param name="json">The json.</param> /// <returns></returns> public static bool Compute(IBooleanComputable computableObject, JObject json) { if (json != null) { ICriteriaOperatorComputable operatorComputable = computableObject as ICriteriaOperatorComputable; if (operatorComputable != null) { return(BooleanCompute(operatorComputable, json)); } IRelationshipOperatorComputable relationshipComputable = computableObject as IRelationshipOperatorComputable; if (relationshipComputable != null) { return(BooleanCompute(relationshipComputable, json)); } } return(false); }
/// <summary> /// Booleans the compute. /// </summary> /// <param name="operatorComputable">The operator computable.</param> /// <param name="json">The json.</param> /// <returns><c>true</c> if compute as true, <c>false</c> otherwise.</returns> public static bool BooleanCompute(IRelationshipOperatorComputable operatorComputable, JObject json) { bool result = false; if (operatorComputable != null && operatorComputable.ItemLeft != null && operatorComputable.ItemRight != null) { switch (operatorComputable.Operator) { case RelationshipOperator.And: result = operatorComputable.ItemLeft.Compute(json) && operatorComputable.ItemRight.Compute(json); break; case RelationshipOperator.Or: result = operatorComputable.ItemLeft.Compute(json) || operatorComputable.ItemRight.Compute(json); break; default: result = false; break; } } return(result); }