public override bool TryEvaluateToBool(IExpressionContext context, out bool result) { var canEvaluate = expression.TryEvaluateToBool(context, out result); result = !result; return(canEvaluate); }
public override bool TryEvaluateToBool(IExpressionContext context, out bool result) { // Short-circuiting, check only left expr, right // would be required only if left == false if (!left.TryEvaluateToBool(context, out result)) { return(false); } if (result) { return(true); } return(right.TryEvaluateToBool(context, out result)); }
public override bool TryEvaluateToBool(IExpressionContext context, out bool result) { if (left.TryEvaluateToBool(context, out bool l) && right.TryEvaluateToBool(context, out bool r)) { result = BoolCompare(l, r, op); return(true); } if (left.TryEvaluateToVersion(context, out Version vl)) { if (right.TryEvaluateToVersion(context, out Version vr)) { result = VersionCompare(vl, vr, op); return(true); } else if (right.TryEvaluateToNumber(context, out float fr)) { result = VersionCompare(vl, fr, op); return(true); } } else if (left.TryEvaluateToNumber(context, out float fl)) { if (right.TryEvaluateToNumber(context, out float fr)) { result = NumberCompare(fl, fr, op); return(true); } else if (right.TryEvaluateToVersion(context, out Version vr)) { result = VersionCompare(fl, vr, op); return(true); } } if (!left.TryEvaluateToString(context, out string ls) || !right.TryEvaluateToString(context, out string rs)) { result = false; return(false); } result = StringCompare(ls, rs, op); return(true); }