//An easy way to publish all services public static void PublishAllDefault() { Console.WriteLine("Publishing all of the following default services -\nAddTwoNumbers\nAddThreeNumbers\nMulTwoNumbers\nMulThreeNumbers\nIsPrimeNumber\nGenPrimeNumbersToValue\nGenPrimeNumbersInRange"); ServicePublisher publisher = new ServicePublisher(); publisher.PublishAllDefault(); }
public static void Unpublish() { string URL = "https://localhost:44358/"; RestClient client = new RestClient(URL); RestRequest asrequest = new RestRequest("api/allservices/"); PassObject <string> pass = new PassObject <string>(); pass.Token = DataSingleton.Instance.token; asrequest.AddJsonBody(pass); IRestResponse serviceret = client.Post(asrequest); ReturnObject <List <ServiceModel> > services = JsonConvert.DeserializeObject <ReturnObject <List <ServiceModel> > >(serviceret.Content); string[] endpoints = new string[services.Returned.Count]; bool cont = true; do { int count = 0; Console.WriteLine("Please select which of the following services you would like to remove (or enter 0 to return to the menu): "); foreach (ServiceModel service in services.Returned) { endpoints[count] = service.API_Endpoint; Console.WriteLine((count + 1).ToString() + ") " + service.Name); count++; } Console.WriteLine("0) Return to menu"); string entry = Console.ReadLine(); bool isNum = int.TryParse(entry, out int selection); if (!isNum || selection < 0 || selection > count - 1) { Console.WriteLine("Please enter a valid input"); } else { if (selection == 0) { break; } else { cont = false; string endpoint = endpoints[selection - 1]; ServicePublisher servicePublisher = new ServicePublisher(); servicePublisher.Unpublish(endpoint); Console.WriteLine("Service unpublished"); } } }while(cont); }
public static void Publish() { ServiceModel[] services = new ServicePublisher().valid_services; bool cont = true; do { int count = 0; Console.WriteLine("Please select which of the following services you would like to publish (or enter 0 to return to the menu): "); foreach (ServiceModel service in services) { Console.WriteLine((count + 1).ToString() + ") " + service.Name); count++; } Console.WriteLine("0) Return to menu"); string entry = Console.ReadLine(); bool isNum = int.TryParse(entry, out int selection); if (!isNum || selection < 0 || selection > count - 1) { Console.WriteLine("Please enter a valid input"); } else { if (selection == 0) { break; } else { cont = false; ServiceModel ser = services[selection - 1]; ServicePublisher servicePublisher = new ServicePublisher(); servicePublisher.Publish(ser); Console.WriteLine(ser.Name + " has been published"); } } }while (cont); }