Beispiel #1
0
        public static void Main()
        {
            int[] myIntArray = new int[3];

            Console.WriteLine("Watson, come here I need you...");

            // create an Http channel and register it
            // uses port 0 to indicate won't be listening
            HttpChannel chan = new HttpChannel(0);

            ChannelServices.RegisterChannel(chan);

            // get my object from across the http channel
            MarshalByRefObject obj =
                (MarshalByRefObject)RemotingServices.Connect
                    (typeof(Calculator.ICalc),
                    "http://localhost:65100/theEndPoint");

            try
            {
                // cast the object to our interface
                Calculator.ICalc calc = obj as Calculator.ICalc;

                // use the interface to call methods
                double sum        = calc.Add(3.0, 4.0);
                double difference = calc.Sub(3, 4);
                double product    = calc.Mult(3, 4);
                double quotient   = calc.Div(3, 4);

                // print the results
                Console.WriteLine("3+4 = {0}", sum);
                Console.WriteLine("3-4 = {0}", difference);
                Console.WriteLine("3*4 = {0}", product);
                Console.WriteLine("3/4 = {0}", quotient);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Exception caught: ");
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
        static void Main()
        {
            int[] myIntArray = new int[3];

            Console.WriteLine("Watson come here I need you...");

            //stvara http kanal i registrira ga
            //koristi ulaz 0
            HttpChannel chan = new HttpChannel(0);

            ChannelServices.RegisterChannel(chan, false);

            Object obj = RemotingServices.Connect(typeof(Calculator.ICalc), "http://localhost:65100/theEndPoint");

            try
            {
                //pretvara objekat u sucelje
                Calculator.ICalc calc = obj as Calculator.ICalc;

                //koristi sucelje za pozivanje metoda
                double sum        = calc.Add(3.0, 4.0);
                double difference = calc.Sub(3, 4);
                double product    = calc.Mult(3, 4);
                double quotient   = calc.Div(3, 4);

                //ispisuje rezultate
                Console.WriteLine("3 + 4 = {0}", sum);
                Console.WriteLine("3 - 4 = {0}", difference);
                Console.WriteLine("3 * 4 = {0}", product);
                Console.WriteLine("3 / 4 = {0}", quotient);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: {0}", ex.Message);
            }
            Console.WriteLine("Press [ENTER] to exit...");
            Console.ReadKey();
        }