static void Main(string[] args) { Console.WriteLine("Client 1"); MathsOperationsClient client = new MathsOperationsClient("MathsOperations"); Console.WriteLine(client.Add(100, 101)); Console.WriteLine(client.Multiply(10, 15)); Console.WriteLine("Client 2"); MathsOperationsClient client2 = new MathsOperationsClient("MathsBis"); Console.WriteLine(client2.Add(100, 101)); Console.WriteLine(client2.Multiply(10, 15)); try { Console.WriteLine(client2.Divide(10, 0)); } catch (FaultException ex) { Console.WriteLine(ex.Reason); } Console.WriteLine("Client 3"); MathsOperationsClient client3 = new MathsOperationsClient("MathsTriWShttp"); Console.WriteLine(client3.Add(100, 101)); Console.WriteLine(client3.Multiply(10, 15)); Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { int a = 0; int b = 0; if (!int.TryParse(textBox1.Text, out a) || !int.TryParse(textBox2.Text, out b)) { label8.Text = "Erreur veuillez rentrer 2 chiffres corrects"; } else { switch (comboBox2.SelectedItem.ToString()) { case "Addition": label4.Text = clientBase.Add(a, b).ToString(); label6.Text = clientBase.Add(a, b).ToString(); comboBox2.SelectedIndex = -1; textBox1.Clear(); textBox2.Clear(); label8.Text = ""; break; case "Multiplication": label4.Text = clientBase.Multiply(a, b).ToString(); label6.Text = clientBase.Multiply(a, b).ToString(); comboBox2.SelectedIndex = -1; textBox1.Clear(); textBox2.Clear(); label8.Text = ""; break; case "Division": label4.Text = clientBase.Divide(a, b).ToString(); label6.Text = clientBase.Divide(a, b).ToString(); comboBox2.SelectedIndex = -1; textBox1.Clear(); textBox2.Clear(); label8.Text = ""; break; default: label8.Text = "Choisissez une opération svp"; break; } } }
static void Main(string[] args) { MathsOperationsClient client = new MathsOperationsClient(); /* classe d’accès au service */ Console.WriteLine(client.Add(100, 101)); Console.WriteLine(client.Multiply(100, 101)); Console.ReadLine(); }
static void Main(string[] args) { MathsOperationsClient client = new MathsOperationsClient("BasicHTTP"); Console.WriteLine(client.Add(100, 101)); Console.WriteLine(client.Multiply(100, 101)); Console.ReadLine(); }
static void Main(string[] args) { MathsOperationsClient maths = new MathsOperationsClient(); Console.WriteLine(maths.Add(5, 8)); Console.WriteLine(maths.Multiply(40, -985)); Console.WriteLine(maths.Divide(0, 2)); Console.WriteLine(maths.Substract(1, 999)); Console.ReadKey(); }
private static void simpleTest(MathsOperationsClient mathsOperationsClient) { Console.WriteLine("--- 8 + 12 ---"); Console.WriteLine(mathsOperationsClient.Add(8, 12)); Console.WriteLine("--- 20 - 10 ---"); Console.WriteLine(mathsOperationsClient.Subtract(20, 10)); Console.WriteLine("--- 5 * 2.5 ---"); Console.WriteLine(mathsOperationsClient.Multiply(5, 2.5)); Console.WriteLine("--- 20 / 2 ---"); Console.WriteLine(mathsOperationsClient.Divide(50, 2)); }
static void Main(string[] args) { MathsOperationsClient clientSOAP1 = new MathsOperationsClient("SOAPEndPoint1"); MathsOperationsClient clientSOAP2 = new MathsOperationsClient("SOAPEndPoint2"); MathsOperationsClient clientSOAP3 = new MathsOperationsClient("SOAPEndPoint3"); Console.WriteLine("Client SOAP 1"); Console.WriteLine("1 + 2 = {0}", clientSOAP1.Add(1, 2)); Console.WriteLine("2 x 2 = {0}", clientSOAP1.Multiply(2, 2)); Console.WriteLine("5 - 3 = {0}", clientSOAP1.Subtract(5, 3)); Console.WriteLine("3 / 4 = {0}\n", clientSOAP1.Divide(3, 4)); Console.WriteLine("Client SOAP 2"); Console.WriteLine("1 + 4 = {0}", clientSOAP2.Add(1, 4)); Console.WriteLine("2 x 2 = {0}", clientSOAP2.Multiply(2, 2)); Console.WriteLine("5 - 10 = {0}", clientSOAP2.Subtract(5, 10)); Console.WriteLine("3 / 4 = {0}\n", clientSOAP2.Divide(3, 4)); Console.WriteLine("Client SOAP 3"); Console.WriteLine("1 + 4 = {0}", clientSOAP3.Add(1, 4)); Console.WriteLine("2 x 2 = {0}", clientSOAP3.Multiply(2, 2)); Console.WriteLine("5 - 10 = {0}", clientSOAP3.Subtract(5, 10)); Console.WriteLine("3 / 4 = {0}\n", clientSOAP3.Divide(3, 4)); clientSOAP1.Close(); clientSOAP2.Close(); clientSOAP3.Close(); Console.WriteLine("REST Call : Substraction (10 - 9)"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:8733/Design_Time_Addresses/MathsLibrary/MathsOperations/RESTEndPoint/Subtract?x=10&y=9"); //Get the Web Response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); //Setting up the Stream Reader StreamReader readerStream = new StreamReader(responseStream, System.Text.Encoding.GetEncoding("utf-8")); string responseString = readerStream.ReadToEnd(); readerStream.Close(); Console.WriteLine(responseString); Console.ReadLine(); }
private void Mult(object sender, RoutedEventArgs e) { this.res.Text = client.Multiply(int.Parse(this.num1.Text), int.Parse(this.num2.Text)).ToString(); }