コード例 #1
0
ファイル: client.cs プロジェクト: spzenk/sfdocsamples
        static void Main()
        {
            // Create a client to endpoint configuration for ICalculator
            CalculatorClient client = new CalculatorClient();
            Console.WriteLine("Communicate with default ICalculator endpoint.");
            // call operations
            DoCalculations(client);

            //close client and release resources
            client.Close();

            //Create a client to endpoint configuration for ICalculatorSession
            CalculatorSessionClient sClient = new CalculatorSessionClient();

            Console.WriteLine("Communicate with ICalculatorSession endpoint.");
            sClient.Clear();
            sClient.AddTo(100.0D);
            sClient.SubtractFrom(50.0D);
            sClient.MultiplyBy(17.65D);
            sClient.DivideBy(2.0D);
            double result = sClient.Result();
            Console.WriteLine("0, + 100, - 50, * 17.65, / 2 = {0}", result);

            //close client and release resources
            sClient.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
コード例 #2
0
ファイル: client.cs プロジェクト: tian1ll1/WPF_Examples
        static void Main()
        {
            // Create a client with given client endpoint configuration
            CalculatorSessionClient client = new CalculatorSessionClient();

            client.Clear();
            client.AddTo(100.0D);
            client.SubtractFrom(50.0D);
            client.MultiplyBy(17.65D);
            client.DivideBy(2.0D);
            double result = client.Result();
            Console.WriteLine("(((0 + 100) - 50) * 17.65) / 2 = {0}", result);

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }