static void Main(string[] args) { using (UnityContainer container = new UnityContainer()) { ContainerBootstrapper.RegisterTypes(container); Application consoleApp = new Application(); consoleApp.Title = "WELCOME! This program will help you test the Files REST service."; foreach (string commandType in new string[] { "UploadCommand", "GetAllMetadataCommand", "GetMetadataCommand", "DownloadAllCommand", "DownloadCommand", "DeleteCommand", "SettingsCommand" }) { Commands.BaseCommand command = container.Resolve<Commands.BaseCommand>(commandType); consoleApp.AddCommand(command); } Starter.Start(consoleApp); } }
public static void Start(Application application) { using (UnityContainer container = new UnityContainer()) { ContainerBootstrapper.RegisterTypes(container); BaseRuntime runtime = container.Resolve<BaseRuntime>("ApplicationRuntime"); runtime.Execute(application); } }
private void DispatchCommandExecution(Application application, int commandNumber) { try { BaseCommand command = application.GetCommand(commandNumber - 1); commandRuntime.Execute(command); } catch (Exception e) { console.WriteError("Invalid option. Try again."); console.WriteException(e); } }
private bool WasExitCommandEntered(Application application, int commandNumber) { if (commandNumber == application.ExitCommand.ID) { console.WriteLine("Shutting down."); return true; } else { DispatchCommandExecution(application, commandNumber); } return false; }
private void PrintAvailableCommands(Application application) { console.WriteEmptyLine(); console.WriteLine("Main Menu".ToUpper()); console.WriteSingleSeparator(); for (int i = 0; i < application.Commands.Count; i++) { console.WriteLine("{0}) {1}", i + 1, application.Commands[i].Title); } }