/// <summary> /// Get The Implementation ID of the available implementations from user /// </summary> /// <returns>Index of the Implementations chosen by user</returns> public virtual int GetImplementationID() { string returnVal; int retVal; while (true) { returnVal = CUI.ShowImplementations(Name, Implementations); if (string.IsNullOrEmpty(returnVal)) { return(DefaultSubMethod); } else { if (int.TryParse(returnVal, out retVal)) { if (retVal <= Implementations.Count) { return(retVal); } } else { CUI.ErrorMessage(); } } } }
static void Main(string[] args) { int choice; Dictionary <Global.Problems, string> problems = new Dictionary <Global.Problems, string>(); try { problems = ProblemMetaData.GetProblems(); } catch (DynamicProgrammingException ex) { CUI.ShowGeneralInformation(ex.Message + "\nPlease revert any changes you have made to the xml file and try again.\n\nSystem will now exit. Press any key to exit..."); Console.ReadKey(); System.Environment.Exit(0); } while (true) { try { switch (CUI.StartScreen()) { case "1": while (true) { if (problems.Count >= 0 && int.TryParse(CUI.ShowProblemListings(problems), out choice) && problems.Keys.Any(e => (int)e == choice)) { Problem problem = ProblemFactory((Global.Problems)choice); if (problem != null) { problem.Compute(); //problem.StoreResult(); break; } throw new DynamicProgrammingException("A logical exception occurred."); } CUI.ErrorMessage(); } break; case "2": CUI.About(); break; case "3": System.Environment.Exit(0); break; default: CUI.ErrorMessage(); break; } } catch (Exception ex) { if (ex.HandleFatalError()) { System.Environment.Exit(1); } else { ex.Handle(); } } } }