private async Task <double> Visit(BinaryExpression expression) { var left = (dynamic)expression.Left; var right = (dynamic)expression.Right; return(await _sender.GetRespAsync(await Visit(left), await Visit(right), GetOperator(expression))); }
protected override Expression VisitBinary(BinaryExpression node) { Console.WriteLine("Calculating:" + node.ToString()); Expression left = node.Left; Expression right = node.Right; Task <Expression> c1; Task <Expression> c2; c1 = Calculate(left); c2 = Calculate(right); var t = Task.WhenAll(c1, c2); t.Wait(); string op; switch (node.NodeType) { case ExpressionType.Add: op = "+"; break; case ExpressionType.Subtract: op = "-"; break; case ExpressionType.Multiply: op = "*"; break; case ExpressionType.Divide: op = "/"; break; default: throw new ArgumentException(); } var taskAnsw = _sender.GetRespAsync(c1.Result.ToString(), c2.Result.ToString(), op); taskAnsw.Wait(); var answer = Expression.Constant(taskAnsw.Result); Console.WriteLine("Result = " + answer.ToString()); return(answer); }