Beispiel #1
0
        private void Сalculation()
        {
            InstanceContext         instanceContext = new InstanceContext(this);
            CalculatorServiceClient client          = new CalculatorServiceClient(instanceContext);

            try
            {
                switch (_operation)
                {
                case '+':
                    client.Sum(_number1, _number2);
                    break;

                case '-':
                    client.Sub(_number1, _number2);
                    break;

                case '*':
                    client.Mult(_number1, _number2);
                    break;

                case '/':
                    if (_number2 != 0)
                    {
                        client.Div(_number1, _number2);
                    }
                    else
                    {
                        throw new DivideByZeroException();
                    }
                    break;
                }
            }
            //catch (FaultException<ExceptionExType> exception)
            //{
            //    ButtonsEnabled(false);
            //    ExceptionExType exceptionExType = exception.Detail;
            //    MessageBox.Show($"Method name: {exceptionExType.MethodName}\r\n" +
            //                    $"Number line: {exceptionExType.Line}\r\n" +
            //                    $"Description: {exceptionExType.Description}\r\n" +
            //                    $"Message: {exceptionExType.Message}\r\n",
            //                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            //}
            catch (DivideByZeroException)
            {
                Result2.Content = string.Empty;
                Result1.Content = "∞";
                ButtonsEnabled(false);
            }
            catch (Exception)
            {
                ButtonsEnabled(false);
            }
        }