• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CalculatorClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CalculatorClient的典型用法代码示例。如果您正苦于以下问题:C# CalculatorClient类的具体用法?C# CalculatorClient怎么用?C# CalculatorClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: 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


示例2: 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


示例3: Main

 static void Main(string[] args)
 {
     CalculatorClient proxy = new CalculatorClient();
     Console.WriteLine("Client is running at " + DateTime.Now.ToString());
     Console.WriteLine("Sum of two numbers... 5+5 =" + proxy.Add(5, 5));
     Console.ReadLine();
 }
开发者ID:chungvodim,项目名称:HelloWCF,代码行数:7,代码来源:Program.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 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


示例6: 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


示例7: Main

 static void Main(string[] args)
 {
     CalculatorClient client = new CalculatorClient();
     int num1 = 100;
     int num2 = 15;
     Console.WriteLine("Addition {0}, {1} = {2}", num1, num2, client.Addition(num1, num2));
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:7,代码来源:Program.cs


示例8: DemonstrateProblemUsingCanThrow

        // This method shows one problem with the "using" statement.
        //
        // The service Aborts the channel to indicate that the session failed.  When that
        // happens, the client gets an Exception from Close.  Because Dispose is the same as
        // Close, the client gets an Exception from Dispose as well.  The close of the "using"
        // block results in a call to client.Dispose.  Typically developers use "using" to avoid
        // having to write try/catch/finally code.  However, because the closing brace can throw,
        // the try/catch is necessary.
        static void DemonstrateProblemUsingCanThrow()
        {
            Console.WriteLine("=");
            Console.WriteLine("= Demonstrating problem:  closing brace of using statement can throw.");
            Console.WriteLine("=");

            try
            {
                // Create a new client.
                using (CalculatorClient client = new CalculatorClient())
                {
                    // Call Divide and catch the associated Exception.  This throws because the
                    // server aborts the channel before returning a reply.
                    try
                    {
                        client.Divide(0.0, 0.0);
                    }
                    catch (CommunicationException e)
                    {
                        Console.WriteLine("Got {0} from Divide.", e.GetType());
                    }
                }

                // The previous line calls Dispose on the client.  Dispose and Close are the
                // same thing, and the Close is not successful because the server Aborted the
                // channel.  This means that the code after the using statement does not run.
                Console.WriteLine("Hope this code wasn't important, because it might not happen.");
            }
            catch (CommunicationException e)
            {
                // The closing brace of the "using" block throws, so we end up here.  If you
                // want to use using, you must surround it with a try/catch
                Console.WriteLine("Got {0}", e.GetType());
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:43,代码来源:client.cs


示例9: 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


示例10: 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


示例11: 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


示例12: DoCalculations

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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: InvocateGeneratedProxy

 static void InvocateGeneratedProxy()
 {
     using (CalculatorClient calculator = new CalculatorClient())
     {
         Console.WriteLine("x + y = {2} where x = {0}and y = {1} ",1,2,calculator.AddWithTwoOperands(1,2));
         Console.WriteLine("x + y + z = {3} where x = {0}and y = {1} and z = {2}", 1, 2, 3,calculator.AddWithThreeOperands(1, 2,3));
     }
 }
开发者ID:rdzzg,项目名称:LearnningDemo,代码行数:8,代码来源:Program.cs


示例18: 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


示例19: 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


示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Calendar类代码示例发布时间:2022-05-24
下一篇:
C# Calculator类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap