Exemple #1
0
        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));
        }