protected void Calculate(object sender, EventArgs e) { Calculation dto = new Calculation { Operand1 = float.Parse(operand1.Text) }; try { dto.Operand2 = float.Parse(operand2.Text); } catch (FormatException) { dto.Operand2 = 0; } Calculation resultDto; ICalculator proxy = new CalculatorServiceProxy(); try { switch (operation.SelectedValue) { case "Add": resultDto = proxy.Add(dto); break; case "Subtract": resultDto = proxy.Subtract(dto); break; case "Multiply": resultDto = proxy.Multiply(dto); break; case "Divide": resultDto = proxy.Divide(dto); break; case "SquareRoot": resultDto = proxy.SquareRoot(dto); break; default: throw new NotImplementedException(); } result.Text = resultDto.Result.ToString(); PopulateCalculationAudit(); } catch (Exception exception) { statusMessage.Text = exception.Message; } }
static void Main(string[] args) { CalculatorServiceProxy servieProxy1 = new CalculatorServiceProxy("WSHttpBinding_ICalculator"); int addResult = servieProxy1.Add(1, 2); CalculatorServiceProxy serviceProxy2 = new CalculatorServiceProxy("WSHttpBinding_ICalculator1"); int subtractResult = serviceProxy2.Subtract(1, 2); Console.ReadLine(); }