/// <summary> /// Evaluate as boolean /// </summary> internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState state) { ProjectErrorUtilities.VerifyThrowInvalidProject (LeftChild.CanBoolEvaluate(state), state.ElementLocation, "ExpressionDoesNotEvaluateToBoolean", LeftChild.GetUnexpandedValue(state), LeftChild.GetExpandedValue(state), state.Condition); if (LeftChild.BoolEvaluate(state)) { // Short circuit return(true); } else { ProjectErrorUtilities.VerifyThrowInvalidProject (RightChild.CanBoolEvaluate(state), state.ElementLocation, "ExpressionDoesNotEvaluateToBoolean", RightChild.GetUnexpandedValue(state), RightChild.GetExpandedValue(state), state.Condition); return(RightChild.BoolEvaluate(state)); } }
/// <summary> /// Evaluate as boolean /// </summary> internal override bool BoolEvaluate(ConditionEvaluationState state) { ProjectErrorUtilities.VerifyThrowInvalidProject (LeftChild.CanBoolEvaluate(state), state.conditionAttribute, "ExpressionDoesNotEvaluateToBoolean", LeftChild.GetUnexpandedValue(state), LeftChild.GetExpandedValue(state), state.parsedCondition); if (!LeftChild.BoolEvaluate(state)) { // Short circuit return(false); } else { ProjectErrorUtilities.VerifyThrowInvalidProject (RightChild.CanBoolEvaluate(state), state.conditionAttribute, "ExpressionDoesNotEvaluateToBoolean", RightChild.GetUnexpandedValue(state), RightChild.GetExpandedValue(state), state.parsedCondition); return(RightChild.BoolEvaluate(state)); } }
/// <summary> /// Evaluates as boolean and evaluates children as boolean, numeric, or string. /// Order in which comparisons are attempted is numeric, boolean, then string. /// Updates conditioned properties table. /// </summary> internal override bool BoolEvaluate(IConditionEvaluationState state) { // It's sometimes possible to bail out of expansion early if we just need to know whether // the result is empty string. // If at least one of the left or the right hand side will evaluate to empty, // and we know which do, then we already have enough information to evaluate this expression. // That means we don't have to fully expand a condition like " '@(X)' == '' " // which is a performance advantage if @(X) is a huge item list. if (LeftChild.EvaluatesToEmpty(state) || RightChild.EvaluatesToEmpty(state)) { UpdateConditionedProperties(state); return(Compare(LeftChild.EvaluatesToEmpty(state), RightChild.EvaluatesToEmpty(state))); } if (LeftChild.CanNumericEvaluate(state) && RightChild.CanNumericEvaluate(state)) { return(Compare(LeftChild.NumericEvaluate(state), RightChild.NumericEvaluate(state))); } else if (LeftChild.CanBoolEvaluate(state) && RightChild.CanBoolEvaluate(state)) { return(Compare(LeftChild.BoolEvaluate(state), RightChild.BoolEvaluate(state))); } else // string comparison { string leftExpandedValue = LeftChild.GetExpandedValue(state); string rightExpandedValue = RightChild.GetExpandedValue(state); UpdateConditionedProperties(state); return(Compare(leftExpandedValue, rightExpandedValue)); } }
/// <summary> /// Evaluates as boolean and evaluates children as boolean, numeric, or string. /// Order in which comparisons are attempted is numeric, boolean, then string. /// Updates conditioned properties table. /// </summary> internal override bool BoolEvaluate(ConditionEvaluationState state) { ProjectErrorUtilities.VerifyThrowInvalidProject (LeftChild != null && RightChild != null, state.conditionAttribute, "IllFormedCondition", state.parsedCondition); if (LeftChild.CanNumericEvaluate(state) && RightChild.CanNumericEvaluate(state)) { return(Compare(LeftChild.NumericEvaluate(state), RightChild.NumericEvaluate(state))); } else if (LeftChild.CanBoolEvaluate(state) && RightChild.CanBoolEvaluate(state)) { return(Compare(LeftChild.BoolEvaluate(state), RightChild.BoolEvaluate(state))); } else // string comparison { string leftExpandedValue = LeftChild.GetExpandedValue(state); string rightExpandedValue = RightChild.GetExpandedValue(state); ProjectErrorUtilities.VerifyThrowInvalidProject (leftExpandedValue != null && rightExpandedValue != null, state.conditionAttribute, "IllFormedCondition", state.parsedCondition); if (!conditionedPropertiesUpdated) { string leftUnexpandedValue = LeftChild.GetUnexpandedValue(state); string rightUnexpandedValue = RightChild.GetUnexpandedValue(state); if (leftUnexpandedValue != null) { Utilities.UpdateConditionedPropertiesTable (state.conditionedPropertiesInProject, leftUnexpandedValue, rightExpandedValue); } if (rightUnexpandedValue != null) { Utilities.UpdateConditionedPropertiesTable (state.conditionedPropertiesInProject, rightUnexpandedValue, leftExpandedValue); } conditionedPropertiesUpdated = true; } return(Compare(leftExpandedValue, rightExpandedValue)); } }
internal override bool CanBoolEvaluate(ConditionEvaluationState state) { return(LeftChild.CanBoolEvaluate(state)); }