当前位置: 首页>>代码示例>>C#>>正文


C# CalculatorClient.Close方法代码示例

本文整理汇总了C#中CalculatorClient.Close方法的典型用法代码示例。如果您正苦于以下问题:C# CalculatorClient.Close方法的具体用法?C# CalculatorClient.Close怎么用?C# CalculatorClient.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CalculatorClient的用法示例。


在下文中一共展示了CalculatorClient.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InvokeCalculatorService

        static void InvokeCalculatorService(EndpointAddress endpointAddress)
        {
            //create a client
            CalculatorClient client = new CalculatorClient();
            client.Endpoint.Address = endpointAddress;
            Console.WriteLine("Invoking CalculatorService at {0}", endpointAddress);
            double value1 = 100.00D;
            double value2 = 15.99D;

            // Call the Add service operation.
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
            Console.WriteLine();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
开发者ID:Edward-Zhou,项目名称:GettingStartedWCF,代码行数:29,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            CalculatorClient client1 = new CalculatorClient("calculatorservice");
            client1.Open();
            CalculatorClient client2 = new CalculatorClient("calculatorservice");
            client2.Open();

            client1.Close();
            client2.Close();

            Console.WriteLine("ChannelFactory的状态: {0}", client1.ChannelFactory.State);
            Console.WriteLine("ChannelFactory的状态: {0}\n", client2.ChannelFactory.State);

            EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/calculatorservice");
            Binding binding = new WS2007HttpBinding();

            CalculatorClient client3 = new CalculatorClient(binding, address);
            client3.Open();
            CalculatorClient client4 = new CalculatorClient(binding, address);
            client4.Open();

            client3.Close();
            client4.Close();

            Console.WriteLine("ChannelFactory的状态: {0}", client3.ChannelFactory.State);
            Console.WriteLine("ChannelFactory的状态: {0}", client4.ChannelFactory.State);

            Console.Read();
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:29,代码来源:Program.cs

示例3: Main

        static void Main()
        {
            // Create a proxy with given client endpoint configuration
            CalculatorClient client = new CalculatorClient();

            // Call the Add service operation.
            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

            client.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:35,代码来源:client.cs

示例4: Main

        static void Main(string[] args)
        {
            //create an instance of wcf proxy
            CalculatorClient client = new CalculatorClient();
            //call the service operations
            double value1 = 100.00d;
            double value2 = 15.99d;
            double result= client.Add(value1,value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);
            // Call the Subtract service operation.
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

            //Step 3: Closing the client gracefully closes the connection and cleans up resources.
            client.Close();
        }
开发者ID:Edward-Zhou,项目名称:GettingStartedWCF,代码行数:30,代码来源:Program.cs

示例5: Main

        static void Main()
        {
            // Create a client
            CalculatorClient client = new CalculatorClient("NetTcpBinding_ICalculator");

            // Call the Add service operation.
            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, 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();
        }
开发者ID:ssickles,项目名称:archive,代码行数:30,代码来源:Client.cs

示例6: Main

        static void Main(string[] args)
        {
            ServiceReference1.CalculatorClient client = new CalculatorClient();

            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1,value2, result);

            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Substract(value1, value2);
            Console.WriteLine("Substract({0},{1}) = {2}",value1,value2,result);

            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Mutiply({0},{1}) = {2}", value1, value2, result);

            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

            client.Close();

            Console.ReadLine();
        }
开发者ID:siatwangmin,项目名称:GettingStarted,代码行数:28,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            var client = new CalculatorClient();
            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

            client.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
开发者ID:trasa,项目名称:Wotan,代码行数:32,代码来源:Program.cs

示例8: Main

        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();
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:30,代码来源:client.cs

示例9: Main

        static void Main()
        {
            // Create a client to default (http) endpoint configuration 
            CalculatorClient client = new CalculatorClient("default");
            Console.WriteLine("Communicate with http endpoint.");
            // call operations
            DoCalculations(client);
            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();

            // Create a client to tcp endpoint configuration
            client = new CalculatorClient("tcp");
            Console.WriteLine("Communicate with tcp endpoint.");
            // call operations
            DoCalculations(client);
            client.Close();

            // Create a client to named pipe endpoint configuration
            client = new CalculatorClient("namedpipe");
            Console.WriteLine("Communicate with named pipe endpoint.");
            // call operations
            DoCalculations(client);
            client.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:28,代码来源:client.cs

示例10: CallService

        public static void CallService(string endpointName)
        {
            CalculatorClient client = new CalculatorClient(endpointName);

            Console.WriteLine("Calling Endpoint: {0}", endpointName);
            // Call the Add service operation.
            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
            Console.WriteLine();

            client.Close();

        }
开发者ID:ssickles,项目名称:archive,代码行数:33,代码来源:client.cs

示例11: Main

        static void Main(string[] args)
        {
            // Create a proxy with default client endpoint configuration.
            CalculatorClient client = new CalculatorClient();
            // Add
            double value1 = 100.00D;
            double value2 = 15.99D;
            double result = client.Add(value1, value2);
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Subtract
            value1 = 145.00D;
            value2 = 76.54D;
            result = client.Subtract(value1, value2);
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Multiply
            value1 = 9.00D;
            value2 = 81.25D;
            result = client.Multiply(value1, value2);
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Divide
            value1 = 22.00D;
            value2 = 7.00D;
            result = client.Divide(value1, value2);
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, 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();
        }
开发者ID:buihoangthien,项目名称:Nhom6-ThoiKhoaBieuGiangVien,代码行数:35,代码来源:Program.cs

示例12: Main

        static void Main()
        {
            // Create a client with given client endpoint configuration
            CalculatorClient client = new CalculatorClient();

            try
            {
                double value1;
                double value2;
                double result;

                // Call the Multiply service operation with arguments between 1 and 10
                value1 = 2.00D;
                value2 = 5.25D;
                result = client.Multiply(value1, value2);
                Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

                // Call the Multiply service operation with arguments outside 1 and 10
                value1 = 9.00D;
                value2 = 81.25D;
                result = client.Multiply(value1, value2);
                Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);
            }
            catch (FaultException e)
            {
                Console.WriteLine("{0}: {1}", e.GetType(), e.Message);
            }

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

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:35,代码来源:client.cs

示例13: Main

        static void Main(string[] args)
        {
            CalculatorClient svc = new CalculatorClient();

            Console.WriteLine(svc.Add(99.3, 29.8));

            svc.Close();
        }
开发者ID:scottyinthematrix,项目名称:WCFPractice,代码行数:8,代码来源:Program.cs

示例14: Divide

 public double Divide(double n1, double n2)
 {
     CalculatorClient client = new CalculatorClient();
     client.ClientCredentials.UserName.UserName = ServiceSecurityContext.Current.PrimaryIdentity.Name;
     double result = client.Divide(n1, n2);
     client.Close();
     return result;
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:8,代码来源:FacadeService.cs

示例15: GetCallerIdentity

 public string GetCallerIdentity()
 {
     CalculatorClient client = new CalculatorClient();
     client.ClientCredentials.UserName.UserName = ServiceSecurityContext.Current.PrimaryIdentity.Name;
     string result = client.GetCallerIdentity();
     client.Close();
     return result;
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:8,代码来源:FacadeService.cs


注:本文中的CalculatorClient.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。