public string Calculate(string left, string right, string opName) { IBinaryOperation <double> operation = null; try { operation = _operations.First(op => op.Name == opName); } catch (Exception e) { Console.WriteLine(e); throw new InvalidOperationException("Unsupported operation"); } operation.Parse(left.Replace(',', '.'), right.Replace(',', '.')); return(operation.Compute().ToString(CultureInfo.InvariantCulture)); }
public double DoMathOperation(IBinaryOperation calculatorMathOp, double n1, double n2) { return(calculatorMathOp.Compute(n1, n2)); }