Exemplo n.º 1
0
 public static void InvokeService()
 {
     MathProxy.MathClient proxy = new MathClient();
     Console.WriteLine("now watch the service method invocation ");
     Console.WriteLine("Sum ={0}", proxy.Addition(2, 7));
     Console.WriteLine("Sum={0}", proxy.Multiply(2, 7));
 }
Exemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            txtResult.Text = string.Empty;

            try
            {
                _client = new MathClient();
                if (radInt.Checked)
                {
                    int x = Convert.ToInt32(txtX.Text.Trim());
                    int y = Convert.ToInt32(txtY.Text.Trim());
                    txtResult.Text = _client.Add(x, y).ToString();
                }
                else if (radDouble.Checked)
                {
                    double x = Convert.ToDouble(txtX.Text.Trim());
                    double y = Convert.ToDouble(txtY.Text.Trim());
                    txtResult.Text = _client.AddDouble(x, y).ToString();
                }
            }
            catch (Exception ex)
            {
                txtStatus.Text = ex.GetType().ToString();
                MessageBox.Show(ex.Message, "Exception");
            }
        }
Exemplo n.º 3
0
 private void btnDivide_Click(object sender, EventArgs e)
 {
     txtResult.Text = "";
     txtStatus.Text = "";
     try
     {
         _client = new MathClient();
         if (radInt.Checked)
         {
             int x      = Convert.ToInt32(txtX.Text);
             int y      = Convert.ToInt32(txtY.Text);
             int result = _client.Divide(x, y);
             txtResult.Text = result.ToString();
         }
         else if (radDouble.Checked)
         {
             double x      = Convert.ToDouble(txtX.Text);
             double y      = Convert.ToDouble(txtY.Text);
             double result = _client.DivideDouble(x, y);
             txtResult.Text = result.ToString();
         }
     }
     catch (FaultException <DivideByZeroException> ex)
     {
         txtStatus.Text = ex.GetType().ToString();
         MessageBox.Show(ex.Message, "DivideByZeroException");
     }
     catch (Exception ex)
     {
         txtStatus.Text = ex.GetType().ToString();
         MessageBox.Show(ex.Message, "Exception");
     }
 }
Exemplo n.º 4
0
        private void buttonSubtract_Click(object sender, EventArgs e)
        {
            txtResult.Text = string.Empty;

            try
            {
                _client = new MathClient();

                if (radInt.Checked)
                {
                    int.TryParse(txtX.Text.Trim(), out int x);
                    int.TryParse(txtY.Text.Trim(), out int y);
                    txtResult.Text = _client.Subtract(x, y).ToString();
                }
                else if (radDouble.Checked)
                {
                    Double.TryParse(txtX.Text.Trim(), out double x);
                    Double.TryParse(txtY.Text.Trim(), out double y);
                    txtResult.Text = _client.SubtractDouble(x, y).ToString();
                }
            }
            catch (Exception ex)
            {
                txtStatus.Text = ex.GetType().ToString();
                MessageBox.Show(ex.Message, "Exception");
            }
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     using (MathClient proxy = new MathClient())
     {
     }
 }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            MathClient.start();
//            InfoClient.start();
        }
Exemplo n.º 7
0
        MathClient _client;  // MathClient这个类名来自于自动生成的Reference.cs文件中

        private void FrmCalculator_Load(object sender, EventArgs e)
        {
            _client = new MathClient();
        }