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(); }
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); }
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(); }
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(); }
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)); }
// 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()); } }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
static void Main(string[] args) { CalculatorClient svc = new CalculatorClient(); Console.WriteLine(svc.Add(99.3, 29.8)); svc.Close(); }
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; }
public string GetCallerIdentity() { CalculatorClient client = new CalculatorClient(); client.ClientCredentials.UserName.UserName = ServiceSecurityContext.Current.PrimaryIdentity.Name; string result = client.GetCallerIdentity(); client.Close(); return result; }
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)); } }
static void Main(string[] args) { CalculatorClient client = new CalculatorClient(); Console.WriteLine(client.Add(10, 20)); Console.ReadKey(); client.Close(); }
static void Main(string[] args) { CalculatorClient client = new CalculatorClient(); // 使用 "client" 变量在服务上调用操作。 var result = client.Add(1, 2); // 始终关闭客户端。 client.Close(); }
private void button1_Click(object sender, RoutedEventArgs e) { using (var proxy = new CalculatorClient()) { int result1 = proxy.Add(1, 2); double result2 = proxy.Add(1.0, 2.0); labelUsualResult.Content = string.Format("int: {0}, double: {1}", result1, result2); } }
static void Main(string[] args) { var service = new CalculatorClient(); Point a = new Point(){X = 4,Y=5}; Point b = new Point(){X = 2, Y = 3}; Console.WriteLine(string.Format("the distance is {0:0.00}", service.CalcDistance(a, b))); }
static void Main() { // Create a client with Certificate endpoint configuration CalculatorClient client = new CalculatorClient("Certificate"); try { client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "alice"); // 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(); } catch (TimeoutException e) { Console.WriteLine("Call timed out : {0}", e.Message); client.Abort(); } catch (CommunicationException e) { Console.WriteLine("Call failed : {0}", e.Message); client.Abort(); } catch (Exception e) { Console.WriteLine("Call failed : {0}", e.Message); client.Abort(); } Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); }
static void Main() { Point pointA = new Point(1, 2), pointB = new Point(5, 3); var client = new CalculatorClient(); var pointsDistance = client.CalcDistance(pointA, pointB); Console.WriteLine("Distance between point A and point B: {0}", pointsDistance); }
public static void Main() { CalculatorClient client = new CalculatorClient(); var pointA = new Point(4, 5); var pointB = new Point(3, 4); var result = client.CalcDistance(pointA, pointB); Console.WriteLine("Distance: {0}", result); }
static void Main() { // Create a client with given client endpoint configuration CalculatorClient client = new CalculatorClient(); try { // Call the Add service operation. int value1 = 15; int value2 = 3; int result = client.Add(value1, value2); Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); // Call the Subtract service operation. value1 = 145; value2 = 76; result = client.Subtract(value1, value2); Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); // Call the Multiply service operation. value1 = 9; value2 = 81; result = client.Multiply(value1, value2); Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); // Call the Divide service operation - trigger a divide by zero error. value1 = 22; value2 = 0; 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(); } catch (FaultException<MathFault> e) { Console.WriteLine("FaultException<MathFault>: Math fault while doing " + e.Detail.Operation + ". Problem: " + e.Detail.ProblemType); client.Abort(); } catch (FaultException e) { Console.WriteLine("Unknown FaultException: " + e.GetType().Name + " - " + e.Message); client.Abort(); } catch (Exception e) { Console.WriteLine("EXCEPTION: " + e.GetType().Name + " - " + e.Message); client.Abort(); } Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Starting client application"); CalculatorClient client = new CalculatorClient(); Console.WriteLine("Performing Addition"); Console.WriteLine(client.Addition(100, 100)); Console.WriteLine("Performing Multiplication"); Console.WriteLine(client.Mulitplication(2, 10)); Console.WriteLine("Press <Enter> to close the application"); Console.ReadLine(); }
static void Main(string[] args) { var client = new CalculatorClient(); Console.WriteLine("{0} + {1} = {2}", 2, 3, client.Add(2, 3)); Console.WriteLine("{0} - {1} = {2}", 2, 3, client.Subtract(2, 3)); Console.WriteLine("{0} * {1} = {2}", 2, 3, client.Multiply(2, 3)); Console.WriteLine("{0} / {1} = {2}", 2, 3, client.Divide(2, 3)); Console.ReadLine(); client.Close(); }
private void ClientRun() { //<snippet16> // Create the binding. WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Message; myBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; // Create the endpoint address. EndpointAddress ea = new EndpointAddress("http://machineName/Calculator"); // Create the client. CalculatorClient cc = new CalculatorClient(myBinding, ea); // Set the user name and password. The code to // return the user name and password is not shown here. Use // an interface to query the user for the information. cc.ClientCredentials.UserName.UserName = ReturnUsername(); cc.ClientCredentials.UserName.Password = ReturnPassword(); // Begin using the client. try { cc.Open(); Console.WriteLine(cc.Add(200, 1111)); Console.ReadLine(); // Close the client. cc.Close(); } //</snippet16> catch (TimeoutException tex) { Console.WriteLine(tex.Message); cc.Abort(); } catch (CommunicationException cex) { Console.WriteLine(cex.Message); cc.Abort(); } finally { Console.WriteLine("Closed the client"); Console.ReadLine(); } }
static void Main(string[] args) { //CalculatorClient calculatorClient = new CalculatorClient(); //Console.WriteLine("Calculator work demonsration:" + Environment.NewLine); //Console.WriteLine("3 + 5 = {0}", calculatorClient.Add(3, 5)); //Console.WriteLine("7 - 2 = {0}", calculatorClient.Subtract(7, 2)); //Console.WriteLine("15 / 7 = {0}", calculatorClient.Divide(15, 7)); //Console.WriteLine("2 * 3 = {0}", calculatorClient.Multiply(2, 3)); //Console.WriteLine(); //Console.WriteLine("Fault demonstration:" + Environment.NewLine); //Console.WriteLine("5 / 0 :"); //FaultTest(() => calculatorClient.Divide(5, 0)); //Console.WriteLine("<double.MaxValue> + <double.MaxValue>:"); //FaultTest(() => calculatorClient.Add(double.MaxValue, double.MaxValue)); //Console.WriteLine("<double.MaxValue> * <double.MaxValue>:"); //FaultTest(() => calculatorClient.Multiply(double.MaxValue, double.MaxValue)); //Console.WriteLine("<double.MaxValue>^2:"); //FaultTest(() => calculatorClient.Sqr(double.MaxValue)); //Console.WriteLine("(<double.MinValue> - <double.MaxValue>:"); //FaultTest(() => calculatorClient.Subtract(double.MinValue, double.MaxValue)); //calculatorClient.Close(); //Console.ReadKey(); CalculatorClient calculatorClient = new CalculatorClient(); while (true) { try { Console.WriteLine("Calculator is ready!"); ExecuteOperation(calculatorClient); } catch (Exception) { Console.WriteLine("Invalid operand"); } Console.WriteLine(); } }
static void Main(string[] args) { // Create a client with given client endpoint configuration CalculatorClient client = new CalculatorClient(); // Perform addition using a typed message. MyMessage request = new MyMessage(); request.N1 = 100D; request.N2 = 15.99D; request.Operation = "+"; MyMessage response = ((ICalculator)client).Calculate(request); Console.WriteLine("Add({0},{1}) = {2}", request.N1, request.N2, response.Result); // Perform subtraction using a typed message. request = new MyMessage(); request.N1 = 145D; request.N2 = 76.54D; request.Operation = "-"; response = ((ICalculator)client).Calculate(request); Console.WriteLine("Subtract({0},{1}) = {2}", request.N1, request.N2, response.Result); // Perform multiplication using a typed message. request = new MyMessage(); request.N1 = 9D; request.N2 = 81.25D; request.Operation = "*"; response = ((ICalculator)client).Calculate(request); Console.WriteLine("Multiply({0},{1}) = {2}", request.N1, request.N2, response.Result); // Perform multiplication using a typed message. request = new MyMessage(); request.N1 = 22D; request.N2 = 7D; request.Operation = "/"; response = ((ICalculator)client).Calculate(request); Console.WriteLine("Divide({0},{1}) = {2}", request.N1, request.N2, response.Result); //Closing the client gracefully closes the connection and cleans up resources Console.WriteLine("closign client"); client.Close(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); }
public void Calculator_AdditionOfTwoPositiveNumbers_ResultIsCorrect() { using (var client = new CalculatorClient()) { client.LaunchApplicationUnderTest(); client.Shell.Enter(1); client.Shell.ButtonAdd.Click(); client.Shell.Enter(299); client.Shell.ButtonEquals.Click(); Assert.AreEqual("300", client.Shell.Result.DisplayText); } }
public void Calculator_Add122And110_ResultIs232() { using (var client = new CalculatorClient()) { client.LaunchApplicationUnderTest(); client.Shell.Enter(122); client.Shell.ButtonAdd.Click(); client.Shell.Enter(110); client.Shell.ButtonEquals.Click(); Assert.AreEqual("232", client.Shell.Result.DisplayText); } }
public void Calculator_Add1And2_ResultIs3() { using (var client = new CalculatorClient()) { client.LaunchApplicationUnderTest(); client.Shell.Button1.Click(); client.Shell.ButtonAdd.Click(); client.Shell.Button2.Click(); client.Shell.ButtonEquals.Click(); Assert.AreEqual("3", client.Shell.Result.DisplayText); } }
static void p_PingCompleted(object sender, PingCompletedEventArgs e) { string ip = (string)e.UserState; if (e.Reply != null && e.Reply.Status == IPStatus.Success) { if (resolveNames) { string name; try { IPHostEntry hostEntry = Dns.GetHostEntry(ip); name = hostEntry.HostName; //ServiceController[] services = ServiceController.GetServices(name); //Console.WriteLine("=== Services on {0} ===", name); //foreach(var service in services) //{ // Console.WriteLine("- {0} : {1}", service.ServiceType, service.ServiceName); //} //var myService = services.FirstOrDefault(s => s.ServiceName == "CalculatorService"); //Console.WriteLine("=== End === Found: {0}", (myService != null)); CalculatorClient client = new CalculatorClient(new BasicHttpBinding(), new EndpointAddress("http://" + ip + ":8000/WCF/Service/CalculatorService")); client.SendMessage("Hello"); Console.WriteLine("! Message sent !"); } catch (Exception ex) { Console.WriteLine("--Excepiton: {0}--", ex.Message); if (ex.InnerException != null) { Console.WriteLine("--Inner: {0}--", ex.InnerException.Message); } name = "?"; } Console.WriteLine("{0} ({1}) is up: ({2} ms)", ip, name, e.Reply.RoundtripTime); } else { Console.WriteLine("{0} is up: ({1} ms)", ip, e.Reply.RoundtripTime); } } else if (e.Reply == null) { Console.WriteLine("Pinging {0} failed. (Null Reply object?)", ip); } else { //Console.WriteLine("Pinging {0} failed. Status: {1}", ip, e.Reply.Status); } }
protected virtual void OnAdded(IAsyncResult asyncResult) { CalculatorClient proxy = asyncResult.AsyncState as CalculatorClient; if (proxy != null) { if (Added != null) { Added(this, new MathOperationEventArgs { Result = proxy.EndAdd(asyncResult) }); } } }
static void Main(string[] args) { CallbackWCFService.CallBackAction = (s) => { Console.WriteLine(s); }; CallbackWCFService.CallBackEvent += CallbackWCFService_CallBackEvent; InstanceContext instanceContex = new InstanceContext(new CallbackWCFService()); CalculatorClient proxy = new CalculatorClient(instanceContex); proxy.Multiple(2, 3); Console.Read(); }
protected void Button1_Click(object sender, EventArgs e) { try { var client = new CalculatorClient("BasicHttpBinding_ICalculator"); client.ClientCredentials.UserName.UserName = "******"; client.ClientCredentials.UserName.Password = "******"; Response.Write(client.Add(4, 96)); } catch (MessageSecurityException exception) { Response.Write(exception.Message); } }
public static void RunClient() { //<snippet6> // Create the binding. WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; // Create the endpoint address. Note that the machine name // must match the subject or DNS field of the X.509 certificate // used to authenticate the service. EndpointAddress ea = new EndpointAddress("https://machineName/Calculator"); // Create the client. The code for the calculator // client is not shown here. See the sample applications // for examples of the calculator code. CalculatorClient cc = new CalculatorClient(myBinding, ea); // Begin using the client. try { cc.Open(); Console.WriteLine(cc.Add(100, 1111)); // Close the client. cc.Close(); } //</snippet6> catch (TimeoutException tex) { Console.WriteLine(tex.Message); cc.Abort(); } catch (CommunicationException cex) { Console.WriteLine(cex.Message); cc.Abort(); } finally { Console.WriteLine("Closed the client"); Console.ReadLine(); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { CalculatorClient cc = new CalculatorClient("NetTcpBinding_ICalculator"); cc.ClientCredentials.Windows.ClientCredential.UserName = "******"; cc.ClientCredentials.Windows.ClientCredential.Password = "******"; int c = cc.Add(int.Parse(txta.Text), int.Parse(txtb.Text)); Response.Write(c.ToString()); } catch (Exception E1) { Response.Write(E1.Message); } }
public void Add_With_Negative_Numbers_Exception_With_Message() { CalculatorClient calculatorClient = new CalculatorClient(); var exceptionMessage = string.Empty; try { calculatorClient.Add("-1,-2,-3"); } catch (System.Exception ex) { exceptionMessage = ex.Message; } Assert.AreEqual(exceptionMessage, "negatives not allowed: -1,-2,-3"); }
static void Main(string[] args) { CalculatorClient proxy = new CalculatorClient(); int number1 = 0; int number2 = 0; Console.WriteLine("Welcome User!!! \n"); Console.WriteLine("Enter First Number : "); number1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Second Number : "); number2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Addition Result : {0}", proxy.DoAdd(number1, number2)); Console.WriteLine("Subtraction Result : {0}", proxy.DoSubtract(number1, number2)); Console.ReadLine(); }
/// <summary> /// WCF clients and servers can handle messages in three ways: /// 1. Synchronous /// 2. Task-Based Asynchronous Pattern /// 3. IAsyncResult Asynchronous Pattern /// /// In this method, the server's handling is held constant (synchronous endpoint) but the client /// accesses the server using each of the 3 ways. /// </summary> /// <param name="calculator">The calculator client</param> /// <returns></returns> private static async Task <int> Invoke_ServerSyncAdd_Endpoints(CalculatorClient calculator) { int exceptionsSeen = 0; try { Console.WriteLine(); LoggingHelper.WriteLineWithDate($"[Client] Invoke: Sync_ServerSyncAdd(1, 2)"); double result = calculator.Sync_ServerSyncAdd(1, 2); LoggingHelper.WriteLineWithDate($"[Client] Result: {result}"); } catch (Exception ex) { LoggingHelper.WriteLineWithDate($"[Client] Message resulted in an exception. Exception message: {ex.Message}"); exceptionsSeen++; } try { Console.WriteLine(); LoggingHelper.WriteLineWithDate($"[Client] Invoke: Begin_ServerSyncAdd(1, 2)"); IAsyncResult asyncResult = calculator.Begin_ServerSyncAdd(1, 2, null, null); LoggingHelper.WriteLineWithDate($"[Client] Invoke: End_ServerSyncAdd(asyncResult)"); double result = calculator.End_ServerSyncAdd(asyncResult); LoggingHelper.WriteLineWithDate($"[Client] Result: {result}"); } catch (Exception ex) { LoggingHelper.WriteLineWithDate($"[Client] Message resulted in an exception. Exception message: {ex.Message}"); exceptionsSeen++; } try { Console.WriteLine(); LoggingHelper.WriteLineWithDate($"[Client] Invoke: Task_ServerSyncAdd(1, 2)"); double result = await calculator.Task_ServerSyncAdd(1, 2); LoggingHelper.WriteLineWithDate($"[Client] Result: {result}"); } catch (Exception ex) { LoggingHelper.WriteLineWithDate($"[Client] Message resulted in an exception. Exception message: {ex.Message}"); exceptionsSeen++; } return(exceptionsSeen); }
static void Main(string[] args) { ClientBase <OneWayCalculatorClient> .CacheSetting = CacheSetting.Default; WSHttpBinding binding = new WSHttpBinding(); EndpointAddress epAddress = new EndpointAddress("http://localhost:8000/oneway/service"); OneWayCalculatorClient client = new OneWayCalculatorClient(binding, epAddress); // Call the Add service operation. double value1 = 100.00D; double value2 = 15.99D; client.Add(value1, value2); Console.WriteLine("Add({0},{1})", value1, value2); // Call the Subtract service operation. value1 = 145.00D; value2 = 76.54D; client.Subtract(value1, value2); Console.WriteLine("Subtract({0},{1})", value1, value2); // Call the Multiply service operation. value1 = 9.00D; value2 = 81.25D; client.Multiply(value1, value2); Console.WriteLine("Multiply({0},{1})", value1, value2); // Call the Divide service operation. value1 = 22.00D; value2 = 7.00D; client.Divide(value1, value2); Console.WriteLine("Divide({0},{1})", value1, value2); // Call the SayHello service operation string name = "World"; string response = client.SayHello(name); Console.WriteLine("SayHello([0])", name); Console.WriteLine("SayHello() returned: " + response); CalculatorClient client1 = new CalculatorClient(binding, epAddress); client1.AddAsync(1, 2); client1.Add(1, 2); //Closing the client gracefully closes the connection and cleans up resources client.Close(); }
public static void RunClient() { //<snippet4> // Create the binding. NetTcpBinding myBinding = new NetTcpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; // Create the endpoint address. EndpointAddress myEndpointAddress = new EndpointAddress("net.tcp://localhost:8008/Calculator"); // Create the client. The code for the calculator client // is not shown here. See the sample applications // for examples of the calculator code. CalculatorClient cc = new CalculatorClient(myBinding, myEndpointAddress); try { cc.Open(); // Begin using the client. Console.WriteLine(cc.Add(100, 11)); Console.ReadLine(); // Close the client. cc.Close(); } //</snippet4> catch (TimeoutException tex) { Console.WriteLine(tex.Message); cc.Abort(); } catch (CommunicationException cex) { Console.WriteLine(cex.Message); cc.Abort(); } finally { Console.WriteLine("Closed the client"); Console.ReadLine(); } }
private void ResultButton_Click(object sender, EventArgs e) { CalculatorClient simpleCalc; switch (operation) { case 0: break; case 1: simpleCalc = new CalculatorClient("BasicHttpBinding_ICalculator"); result = simpleCalc.Sum(num1, Convert.ToDouble(currentNum)); simpleCalc.Close(); break; case 2: simpleCalc = new CalculatorClient("BasicHttpBinding_ICalculator"); result = simpleCalc.Minus(num1, Convert.ToDouble(currentNum)); simpleCalc.Close(); break; case 3: simpleCalc = new CalculatorClient("BasicHttpBinding_ICalculator"); result = simpleCalc.Mult(num1, Convert.ToDouble(currentNum)); simpleCalc.Close(); break; case 4: try { simpleCalc = new CalculatorClient("BasicHttpBinding_ICalculator"); result = simpleCalc.Div(num1, Convert.ToDouble(currentNum)); simpleCalc.Close(); } catch (DivideByZeroException ex) { MessageBox.Show("Attempt to devide by zero was made!!!"); } break; } currentNum = result.ToString(); textBox1.Text = currentNum; textBox1.Refresh(); num1 = result; calculating = false; result = 0; operation = 0; }
static void Main(string[] args) { CalculatorClient myClient = new CalculatorClient(); int intVal, k = 1; string inpstr, inpcom; while (k == 1) { Console.WriteLine(); Console.WriteLine("What operation you want to perform?(Withdraw,Deposit,Show balance)"); inpstr = Console.ReadLine(); if (inpstr == "Deposit") { Console.WriteLine("Insert number to be deposited to account"); inpcom = Console.ReadLine(); intVal = Convert.ToInt32(inpcom); double result = myClient.Deposit(intVal); Console.WriteLine("Your current balance is equal {0}", result); } if (inpstr == "Withdraw") { Console.WriteLine("Insert value to be withdrawed from your account"); inpcom = Console.ReadLine(); intVal = Convert.ToInt32(inpcom); double result = myClient.Withdraw(intVal); if (result > 0) { Console.WriteLine("Your current balance is equal {0}", result); } else { Console.WriteLine("Operation cannot be performed"); } } if (inpstr == "Show") { double result = myClient.Show(); Console.WriteLine("Your current balance is equal {0}", result); } if (inpstr == "Exit") { k = 0; } } myClient.Close(); }
static void Main(string[] args) { using (CalculatorClient cl = new CalculatorClient()) { //Should probably use this construct instead } //Step 1: Create an instance of the WCF proxy CalculatorClient client = new CalculatorClient(); //Step 2: Call the service operations //Call the Add service operation double value1 = 100.00D; double value2 = 15.99D; double result = client.Add(value1, value2); Console.WriteLine($"value 1:{value1} plus value 2: {value2} eq result: {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.TestMethod()); //When done, make sure to close the client: client.Close(); //MRL Console.ReadLine(); }
static void Main(string[] args) { CalculatorClient client1 = new CalculatorClient("WSHttpBinding_ICalculator"); CalculatorClient client2 = new CalculatorClient("mojEndpoint2"); CalculatorClient client3 = new CalculatorClient("mojEndpoint3"); CalculatorClient client4 = new CalculatorClient("NetTcpBinding_ICalculator"); double value1 = 18; double value2 = 8.5; double result = client1.Add(value1, value2); Console.WriteLine("Wywoluje dodawanie dla klienta1:\t" + value1 + " + " + value2 + " = " + result); result = client1.Multiply(value1, value2); Console.WriteLine("Wywoluje mnozenie dla klienta1:\t" + value1 + " * " + value2 + " = " + result); result = client1.Sum(value1); Console.WriteLine("Wywoluje sumowanie dla klienta1 = " + result); result = client1.Sum(value2); Console.WriteLine("Wywoluje sumowanie dla klienta1 = " + result); result = client2.Substract(value1, value2); Console.WriteLine("Wywoluje odejmowanie dla klienta2:\t" + value1 + " - " + value2 + " = " + result); result = client2.Sum(value1); Console.WriteLine("Wywoluje sumowanie dla klienta2 = " + result); result = client2.Sum(value2); Console.WriteLine("Wywoluje sumowanie dla klienta2 = " + result); result = client3.Add(value1, value2); Console.WriteLine("Wywoluje dodawanie dla klienta3:\t" + value1 + " + " + value2 + " = " + result); result = client3.Sum(value1); Console.WriteLine("Wywoluje sumowanie dla klienta3 = " + result); result = client3.Sum(value2); Console.WriteLine("Wywoluje sumowanie dla klienta3 = " + result); result = client4.Substract(value1, value2); Console.WriteLine("Wywoluje odejmowanie dla klienta1:\t" + value1 + " - " + value2 + " = " + result); result = client4.Multiply(value1, value2); Console.WriteLine("Wywoluje mnozenie dla klienta4 = " + result); result = client4.Sum(value1); Console.WriteLine("Wywoluje sumowanie dla klienta4 = " + result); result = client4.Sum(value2); Console.WriteLine("Wywoluje sumowanie dla klienta4 = " + result); }
static void Main(string[] args) { CalculatorClient client1 = new CalculatorClient("WSHttpBinding_ICalculator"); ComplexNum lz1 = new ComplexNum(1.2, 3.4); ComplexNum lz2 = new ComplexNum(1.2, 3.4); Console.WriteLine("\nClient1"); Console.WriteLine("...called addCNum(...)"); ComplexNum result1 = client1.addCNum(lz1, lz2); Console.WriteLine("addCNum(...) = ({0},{1})", result1.realPart, result1.imagPart); Console.WriteLine("Client1 - STOP"); Console.WriteLine("...call of function 1:"); client1.Function1("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 1 call"); Console.WriteLine("...call of function 2:"); client1.Function2("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 2 call"); Console.WriteLine("...call of function 1:"); client1.Function1("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 1 call"); client1.Close(); Console.WriteLine("CLIENT1 - STOP"); Console.WriteLine("\nCLIENT2:"); CallbackHandler myCallbackHandler = new CallbackHandler(); InstanceContext instanceContext = new InstanceContext(myCallbackHandler); CallbackCalculatorClient client2 = new CallbackCalculatorClient(instanceContext); double value1 = 10; Console.WriteLine("...call of Factorial({0})...", value1); client2.Factorial(value1); value1 = 20; Console.WriteLine("...call of Factorial({0})...", value1); client2.Factorial(value1); int value2 = 2; Console.WriteLine("...call of calculation of something..."); client2.CalcSomething(value2); Console.WriteLine("...now I’m waiting for results"); Thread.Sleep(5000); client2.Close(); Console.WriteLine("CLIENT2 - STOP"); }
private void ClientRun() { //<snippet18> // Create the binding. WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Message; myBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; // Create the endpoint address. EndpointAddress ea = new EndpointAddress("net.tcp://machineName:8008/Calculator"); // Create the client. CalculatorClient cc = new CalculatorClient(myBinding, ea); // Begin using the client. try { cc.Open(); Console.WriteLine(cc.Add(200, 1111)); Console.ReadLine(); // Close the client. cc.Close(); } //</snippet18> catch (TimeoutException tex) { Console.WriteLine(tex.Message); cc.Abort(); } catch (CommunicationException cex) { Console.WriteLine(cex.Message); cc.Abort(); } finally { Console.WriteLine("Closed the client"); Console.ReadLine(); } }
static void Main(string[] args) { var calculatorClient = new CalculatorClient(); var operation = args[0]; var number1 = int.Parse(args[1]); var number2 = int.Parse(args[2]); if (string.Equals(operation, "-Add", StringComparison.OrdinalIgnoreCase)) { var resultAdd = calculatorClient.Add(number1, number2); Console.WriteLine("resultAdd: {0}", resultAdd); } else if (string.Equals(operation, "-Subtract", StringComparison.OrdinalIgnoreCase)) { var resultSubtract = calculatorClient.Subtract(number1, number2); Console.WriteLine("resultSubtract: {0}", resultSubtract); } else if (string.Equals(operation, "-Multiply", StringComparison.OrdinalIgnoreCase)) { var resultMultiply = calculatorClient.Multiply(number1, number2); Console.WriteLine("resultMultiply: {0}", resultMultiply); } else if (string.Equals(operation, "-Divide", StringComparison.OrdinalIgnoreCase)) { var resultDivide = calculatorClient.Divide(number1, number2); Console.WriteLine("resultDivide: {0}", resultDivide); } else if (string.Equals(operation, "-PowerOf", StringComparison.OrdinalIgnoreCase)) { var resultPowerOf = calculatorClient.PowerOf(number1, number2); Console.WriteLine("resultPowerOf: {0}", resultPowerOf); } else { Console.WriteLine("Invalid operation entered"); throw new ArgumentException("Invalid operation entered"); } calculatorClient.Close(); // Console.WriteLine("Press <ENTER> to stop client"); // Console.ReadLine(); }
// This method shows the correct way to clean up a client, including catching the // approprate Exceptions. static void DemonstrateCleanupWithExceptions() { // Create a client CalculatorClient client = new CalculatorClient(); try { // Demonstrate a successful client call. Console.WriteLine("Calling client.Add(0.0, 0.0);"); double addValue = client.Add(0.0, 0.0); Console.WriteLine(" client.Add(0.0, 0.0); returned {0}", addValue); // Demonstrate a failed client call. Console.WriteLine("Calling client.Divide(0.0, 0.0);"); double divideValue = client.Divide(0.0, 0.0); Console.WriteLine(" client.Divide(0.0, 0.0); returned {0}", divideValue); // Do a clean shutdown if everything works. In this sample we do not end up // here, but correct code should Close the client if everything was successful. Console.WriteLine("Closing the client"); client.Close(); } catch (CommunicationException e) { // Because the server suffered an internal server error, it rudely terminated // our connection, so we get a CommunicationException. Console.WriteLine("Got {0} from Divide.", e.GetType()); client.Abort(); } catch (TimeoutException e) { // In this sample we do not end up here, but correct code should catch // TimeoutException when calling a client. Console.WriteLine("Got {0} from Divide.", e.GetType()); client.Abort(); } catch (Exception e) { // In this sample we do not end up here. It is best practice to clean up the // client if some unexpected Exception occurs. Console.WriteLine("Got unexpected {0} from Divide, rethrowing.", e.GetType()); client.Abort(); throw; } }
private static void TestWpfServices() { var serv = new ServiceReference.CalculatorClient(); var result = serv.AddAsync(3, 4).Result; Console.WriteLine(result); var servTopShelf = new CalculatorClient(); var resultTopShelf = servTopShelf.Multiply(2.5, 5); Console.WriteLine($"TopSelf {resultTopShelf}"); var servNoConfig = new MyServiceClient(); var stringResult = servNoConfig.ConvertString(Environment.SystemDirectory); Console.WriteLine($"To Upper {stringResult}"); }
private void ClientRun() { // Create the binding. WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Message; myBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; // Disable credential negotiation and the establishment of // a security context. myBinding.Security.Message.NegotiateServiceCredential = false; myBinding.Security.Message.EstablishSecurityContext = false; // Create the endpoint address. EndpointAddress ea = new EndpointAddress("http://localhost:90/Calculator"); // Create the client. CalculatorClient cc = new CalculatorClient(myBinding, ea); // Specify a certificate to use for authenticating the client. cc.ClientCredentials.ClientCertificate.SetCertificate( StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "Contoso.com"); // Specify a default certificate for the service. cc.ClientCredentials.ServiceCertificate.SetDefaultCertificate( StoreLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindBySubjectName, "cohowinery.com"); // Begin using the client. cc.Open(); Console.WriteLine(cc.Add(200, 1111)); Console.ReadLine(); // Close the client. cc.Close(); }
private static void ExecuteOperation(CalculatorClient calculatorClient) { Console.WriteLine("Enter the first operand:"); double operand1 = GetNumberFromConsole(); Console.WriteLine("Enter the operation type:"); Operation operation = GetOperationFromConsole(); if (operation == Operation.InvalidOperation) { Console.WriteLine("Invalid operation"); return; } if (operation == Operation.Square) { FaultTest(() => calculatorClient.Sqr(operand1)); } else { Console.WriteLine("Enter the second operand:"); double operand2 = GetNumberFromConsole(); switch (operation) { case Operation.Add: FaultTest(() => calculatorClient.Add(operand1, operand2)); break; case Operation.Subtract: FaultTest(() => calculatorClient.Subtract(operand1, operand2)); break; case Operation.Multiply: FaultTest(() => calculatorClient.Multiply(operand1, operand2)); break; case Operation.Divide: FaultTest(() => calculatorClient.Divide(operand1, operand2)); break; } } }
private static void Main(string[] args) { using (var client = new CalculatorClient()) { Console.WriteLine(client.Addition(1, 4)); var complexAdditionResult = client.ComplexAddition( new ComplexNumber { Real = 2, Imagine = 4 }, new ComplexNumber { Real = 1, Imagine = 3, }); Console.WriteLine($"Real: {complexAdditionResult.Real}; Imagine: {complexAdditionResult.Imagine}i"); } }
static void Main(string[] args) { var client1 = new CalculatorClient("WSHttpBinding_ICalculator"); var client2 = new CalculatorClient("WSHttpBinding_ICalculator1"); var client3 = new CalculatorClient("WSHttpBinding_ICalculator2"); var client4 = new CalculatorClient("NetTcpBinding_ICalculator"); var value1 = 12.0; var value2 = 4.0; // var result = client.Dodaj(value1, value2); // Console.WriteLine("Wynik dodawania: {0}", result); // result = client.Odejmij(value1, value2); // Console.WriteLine("Wynik odejmowania: {0}", result); // result = client.Pomnoz(value1, value2); // Console.WriteLine("Wynik mnozenia: {0}", result); // client.Close(); client1.Dodaj(12, 0.8); client2.Odejmij(12, 9.3); client3.Pomnoz(12, 2.5); foreach (var client in new List <CalculatorClient>() { client1, client2, client3, client4 }) { client.Sumuj(10); } int i = 1; new List <double>() { client1.Sumuj(1), client2.Sumuj(2), client3.Sumuj(3), client4.Sumuj(4) }.ForEach(r => Console.WriteLine("Klient {0}, rezultat: {1}", i++, r)); Console.ReadLine(); }