added samples
[windows-sources.git] / sdk / samples / WCFSamples / TechnologySamples / Basic / Binding / Custom / Security / CS / client / client.cs
blob80eb077f233cdc71295ef86fd91f66c8702a45e9
2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 using System;
5 using System.ServiceModel;
7 namespace Microsoft.ServiceModel.Samples
9 //The service contract is defined in generatedClient.cs, generated from the service by the svcutil tool.
11 // Define class which implements callback interface of duplex contract
12 public class CallbackHandler : ICalculatorDuplexCallback
14 public void Result(double result)
16 Console.WriteLine("Result({0})", result);
19 public void Equation(string eqn)
21 Console.WriteLine("Equation({0})", eqn);
25 //Client implementation code.
26 class Client
28 static void Main()
32 // Construct InstanceContext to handle messages on callback interface
33 InstanceContext site = new InstanceContext(new CallbackHandler());
35 // Create a client with given client endpoint configuration
36 CalculatorDuplexClient client = new CalculatorDuplexClient(site);
38 Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
39 Console.WriteLine();
41 // Call the AddTo service operation.
42 double value = 100.00D;
43 client.AddTo(value);
45 // Call the SubtractFrom service operation.
46 value = 50.00D;
47 client.SubtractFrom(value);
49 // Call the MultiplyBy service operation.
50 value = 17.65D;
51 client.MultiplyBy(value);
53 // Call the DivideBy service operation.
54 value = 2.00D;
55 client.DivideBy(value);
57 // Complete equation
58 client.Clear();
60 Console.ReadLine();
62 //Closing the client gracefully closes the connection and cleans up resources
63 client.Close();