//GetWebServices() // //Initialization function. //Reads the config file and returns a class containing relevant information on //the webservices and methods documented in the config file. private MultipleWebServices GetWebServices() { string myConfigFileData = ""; MyErrorMessage = ""; // reset error message MultipleWebServices webServices = new MultipleWebServices(); // read config file try { myConfigFileData = System.IO.File.ReadAllText(MyConstants.ConfigFileRelativePath); } catch (Exception ex) { MyErrorMessage = "There was a problem reading the config file. Exception message: " + ex.Message; } //parse config file into an object try { webServices = new JavaScriptSerializer().Deserialize <MultipleWebServices>(myConfigFileData); //check if we actually have some objects if (MyErrorMessage == "" && (webServices == null || webServices.WebServicesList == null || webServices.WebServicesList.Count <= 0)) { MyErrorMessage = "No objects/services were read from the config file."; } } catch (Exception ex) { MyErrorMessage = "There was a problem de-serializing the JSON object in the config file. Exception message: " + ex.Message; } return(webServices); }
//Form1() // //Initialization function. //Initializes a nummber of UI and backend features such as the method and service lists. public Form1() { InitializeComponent(); AvailibleWebServices = GetWebServices(); // check if there was an error if (MyErrorMessage != "") { DisplayErrorMessage(MyErrorMessage); } else { //we have the services, so populate the 'Services' drop down foreach (var service in AvailibleWebServices.WebServicesList) { ddlWebService.Items.Add(service.WebServiceName); } //set the default for the selected web service if (ddlWebService.Items.Count > 0) { ddlWebService.SelectedIndex = 0; } } }