Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            MyNumbers obj = new MyNumbers();
            obj.Number1 = Convert.ToInt32(textBox1.Text);
            obj.Number2 = Convert.ToInt32(textBox2.Text);

            textBox3.Text = channel.Subtract(obj).ToString();
        }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            MathServiceLibrary.MyNumbers obj = new MathServiceLibrary.MyNumbers();
            obj.Number1 = Convert.ToInt32(textBox1.Text);
            obj.Number2 = Convert.ToInt32(textBox2.Text);

            textBox3.Text = channel.Subtract(obj).ToString();
        }
Esempio n. 3
0
        private void btnSubtract_Click(object sender, EventArgs e)
        {
            var myNum = new MathServiceLibrary.MyNumbers
            {
                Number1 = int.Parse(txtNumber1.Text),
                Number2 = int.Parse(txtNumber2.Text)
            };

            txtResult.Text = _channel.Subtract(myNum).ToString();
        }
Esempio n. 4
0
        public void DivideInOneWay(MyNumbers obj)
        {
            int result = 0;

            try
            {
                result = obj.Number1 / obj.Number2;
            }
            catch (System.DivideByZeroException dbze)
            {
                throw new DivideByZeroException(dbze.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            //return (result);
        }
Esempio n. 5
0
        public int Divide(MyNumbers obj)
        {
            int result = 0;

            try
            {
                if (obj.Number2 > 100)
                {
                    throw new FaultException("Value of B cannot be above 100", new FaultCode("BValueIsAboveHundred"));
                }



                result = obj.Number1 / obj.Number2;
            }
            //catch(System.DivideByZeroException dbze)
            //{
            //    throw new DivideByZeroException(dbze.Message);
            //}

            //catch (Exception ex)
            //{
            //    //throw new Exception(ex.Message);
            //    //throw new FaultException("Vaue of B cannot be zero.");
            //    if (!ex.Message.Equals("Value of B cannot be above 100"))
            //        throw new FaultException("Value of B cannot be zero", new FaultCode("BValueIsZero"));
            //    else
            //        throw new FaultException("Value of B cannot be above 100", new FaultCode("BValueIsAboveHundred"));
            //}

            catch (Exception ex)
            {
                var divisionFault = new DivisionFault();
                divisionFault.Method = "Divide";
                divisionFault.Reason =
                    "Value of B cannot be zero";
                divisionFault.Message = ex.Message;
                throw new FaultException <DivisionFault>(divisionFault);
            }

            return(result);
        }
Esempio n. 6
0
        public int Divide(MyNumbers Obj)
        {
            int result = 0;

            // In WCF .Net Exceptions are not recommended
            // Best practise is Fault exceptions (Fault contracts)
            try
            {
                if (Obj.Number2 > 100)
                {
                    throw new Exception("Wrong Value");
                }

                result = Obj.Number1 / Obj.Number2;
            }
            //catch (System.DivideByZeroException dex)
            //{
            //    throw new DivideByZeroException(dex.Message);
            //}
            //catch (Exception ex)
            //{
            //    //throw new Exception(ex.Message);
            //    if (ex.Message.StartsWith("Wrong"))
            //        throw new FaultException("Value of divisor cannot be above 100!!!!", new FaultCode("DivisorAbove100"));
            //    else
            //        throw new FaultException("Division by zero!!!!", new FaultCode("DivisorIsZero"));
            //}
            catch (Exception ex)
            {
                var df = new DivisionFault
                {
                    Method  = "Divide",
                    Reason  = "Divisor value cannot be zero",
                    Message = ex.Message
                };

                throw new FaultException <DivisionFault>(df);
            }


            return(result);
        }
Esempio n. 7
0
 public int Subtract(MyNumbers Obj)
 {
     _counter++;
     return(Obj.Number1 - Obj.Number2);
 }
Esempio n. 8
0
 public int Add(MyNumbers Obj)
 {
     _counter++;
     return(Obj.Number1 + Obj.Number2);
 }
 public int Subtract(MyNumbers obj)
 {
     return (obj.Number1 - obj.Number2);
 }
        //public string GetData(int value)
        //{
        //    return string.Format("You entered: {0}", value);
        //}

        //public CompositeType GetDataUsingDataContract(CompositeType composite)
        //{
        //    if (composite == null)
        //    {
        //        throw new ArgumentNullException("composite");
        //    }
        //    if (composite.BoolValue)
        //    {
        //        composite.StringValue += "Suffix";
        //    }
        //    return composite;
        //}
        public int Add(MyNumbers obj)
        {
            return (obj.Number1 + obj.Number2);
        }
Esempio n. 11
0
 public int Subtract(MyNumbers obj)
 {
     return(obj.Number1 - obj.Number2);
 }
Esempio n. 12
0
 public int Add(MyNumbers obj)
 {
     return(obj.Number1 + obj.Number2);
 }
Esempio n. 13
0
 public int Subtract(MyNumbers Obj)
 {
     return(Obj.Number1 - Obj.Number2);
 }
Esempio n. 14
0
 public int Add(MyNumbers Obj)
 {
     return(Obj.Number1 + Obj.Number2);
 }
Esempio n. 15
0
 public int Mutiply(MyNumbers obj)
 {
     return(obj.Number1 * obj.Number2);
 }
Esempio n. 16
0
 public void DivideOneWay(MyNumbers Obj)
 {
     Divide(Obj);
 }