public ValueExpression Evaluate() { var leftValue = LeftExpression.Evaluate().Value; var rightValue = RightExpression.Evaluate().Value; switch (Operator) { case Operator.Plus: return(new ValueExpression { Value = leftValue + rightValue }); case Operator.Minus: return(new ValueExpression { Value = leftValue - rightValue }); case Operator.Asterisk: return(new ValueExpression { Value = leftValue * rightValue }); case Operator.Slash: return(new ValueExpression { Value = leftValue / rightValue }); } throw new InvalidOperationException(); }
public override Object Evaluate() { object left = LeftExpression.Evaluate(); object right = RightExpression.Evaluate(); if (left is Complex) { if (right is Complex) { return(EvaluateComplexComplex((Complex)left, (Complex)right)); } else { throw ThrowWrongArgumentType("^"); } } else if (left is CMatrix) { if (right is Complex) { return(EvaluateCMatrixComplex((CMatrix)left, (Complex)right)); } else { throw ThrowWrongArgumentType("^"); } } else { throw ThrowWrongArgumentType("^"); } }
/// <summary> /// Evaluates the expression. /// </summary> /// <param name="context">Evaluation context.</param> /// <returns>Expression result.</returns> protected override object EvaluateNode(LogEventInfo context) { object v1 = LeftExpression.Evaluate(context); object v2 = RightExpression.Evaluate(context); return(Compare(v1, v2, RelationalOperator) ? BoxedTrue : BoxedFalse); }
/// <summary> /// Evaluates the expression. /// </summary> /// <param name="context">Evaluation context.</param> /// <returns>Expression result.</returns> protected override object EvaluateNode(LogEventInfo context) { var v1 = LeftExpression.Evaluate(context); var v2 = RightExpression.Evaluate(context); return(Compare(v1, v2, RelationalOperator)); }
public override double Evaluate() { double left = LeftExpression.Evaluate(); double right = RightExpression.Evaluate(); return(left + Random.NextDouble() * (right - left)); }
public override int Evaluate() { if (RightExpression.Evaluate() == 0) { throw new DivideByZeroException("divide by zero exception"); } return(LeftExpression.Evaluate() / RightExpression.Evaluate()); }
/// <summary> /// Evaluates the expression by evaluating <see cref="LeftExpression"/> and <see cref="RightExpression"/> recursively. /// </summary> /// <param name="context">Evaluation context.</param> /// <returns>The value of the alternative operator.</returns> protected override object EvaluateNode(LogEventInfo context) { var bval1 = (bool)LeftExpression.Evaluate(context); if (bval1) { return(BoxedTrue); } var bval2 = (bool)RightExpression.Evaluate(context); if (bval2) { return(BoxedTrue); } return(BoxedFalse); }
public override int Evaluate() { return(LeftExpression.Evaluate() + RightExpression.Evaluate()); }
public override QValue Evaluate() { return(((IntValue)LeftExpression.Evaluate()).SmTh((IntValue)RightExpression.Evaluate())); }
public override QValue Evaluate() { return(((BoolValue)LeftExpression.Evaluate()).Or((BoolValue)RightExpression.Evaluate())); }
public override int Evaluate() { return LeftExpression.Evaluate() * RightExpression.Evaluate(); }
public override double Evaluate() { return(Math.Atan2(LeftExpression.Evaluate(), RightExpression.Evaluate())); }
public override double Evaluate() { return(LeftExpression.Evaluate() / RightExpression.Evaluate()); }