/// <summary> /// Builds the <c>CalcOperation</c>. /// </summary> public CalcOperation Build() { if (Operator == null) { throw new InvalidOperationException("CalcOperations cannot be built without an operator."); } string operType = Operator.GetType().Name; // Postfix and Binary operators require a left operand. if (!(Operator is CLPrefixOperator)) { if (LeftExp != null) { Left = LeftExp.Build(); } if (LeftObj == null) { throw new InvalidOperationException(operType + " requires a left-side operand."); } } else { LeftObj = null; } // Prefix and Binary operators require a left operand. if (!(Operator is CLPostfixOperator)) { if (RightExp != null) { Right = RightExp.Build(); } if (RightObj == null) { throw new InvalidOperationException(operType + " requires a right-side operand."); } } else { RightObj = null; } return(new CalcOperation(LeftObj, Operator, RightObj)); }