private async void CustomOnClickEvent(object sender, EventArgs e, ButtonType type) { try { switch (type) { case ButtonType.B1: mainTextBox.Text += await webServiceManager.GetDataFromServiceAsync("arrays", "[1, 3, 5]") + "\n"; MessageBox.Show("Test data is array [1, 3, 5]", "Test data info"); break; case ButtonType.B2: mainTextBox.Text += await webServiceManager.GetDataFromServiceAsync("average", "[1, 3, 5]") + "\n"; MessageBox.Show("Test data is array [1, 3, 5]", "Test data info"); break; case ButtonType.B3: mainTextBox.Text += await webServiceManager.GetDataFromServiceAsync("multiplication", "{\"x\":5,\"y\":4}") + "\n"; MessageBox.Show("Test data is x = 5; y = 4", "Test data info"); break; case ButtonType.B4: mainTextBox.Text += await webServiceManager.GetDataFromServiceAsync("sorting", "{\"numbers\": [1, 78, 27, 3],\"sortType\":0}") + "\n"; MessageBox.Show("Test data is array [1, 78, 27, 3]", "Test data info"); break; case ButtonType.B5: mainTextBox.Text += await webServiceManager.GetDataFromServiceAsync("sorting", "{\"numbers\": [1, 78, 27, 3],\"sortType\":1}") + "\n"; MessageBox.Show("Test data is array [1, 78, 27, 3]", "Test data info"); break; case ButtonType.B6: Environment.Exit(0); break; } } catch { MessageBox.Show("Server unreachable. Please check server state", "Error"); } }
static async Task Main() { try { WebServiceManager webServiceManager = new WebServiceManager(port); DrawInfoMessage("Test data is array[1, 3, 5]"); Console.WriteLine(await webServiceManager.GetDataFromServiceAsync("arrays", "[1, 3, 5]")); Console.WriteLine(); DrawInfoMessage("Test data is array[1, 3, 5]"); Console.Write("Array average is "); Console.WriteLine(await webServiceManager.GetDataFromServiceAsync("average", "[1, 3, 5]")); Console.WriteLine(); int x = 5, y = 4; DrawInfoMessage($"Test data is x = {x}; y = {y}"); Console.Write($"{x}x{y}="); Console.WriteLine(await webServiceManager.GetDataFromServiceAsync("multiplication", "{\"x\":5,\"y\":4}")); Console.WriteLine(); DrawInfoMessage("Test data is array [1, 78, 27, 3]"); Console.Write("Array sorted in ascending order: "); Console.WriteLine(await webServiceManager.GetDataFromServiceAsync("sorting", "{\"numbers\": [1, 78, 27, 3],\"sortType\":0}")); Console.WriteLine(); DrawInfoMessage("Test data is array [1, 78, 27, 3]"); Console.Write("Array sorted in descending order: "); Console.WriteLine(await webServiceManager.GetDataFromServiceAsync("sorting", "{\"numbers\": [1, 78, 27, 3],\"sortType\":1}")); } catch { Console.Clear(); DrawErrorMessage("Server unreachable. Please check server state"); } Console.ReadKey(true); }