public void Run() { this.dBInitializerService.InitializeDb(); this.writer.WriteLine(string.Format(OutputMsg.AvailableCommands, Environment.NewLine)); foreach (var cmd in (AvailableCommands[])Enum.GetValues(typeof(AvailableCommands))) { this.writer.WriteLine(cmd.ToString()); } while (true) { this.writer.Write(OutputMsg.InsertCommand); var input = reader.Read().Split(" ", StringSplitOptions.RemoveEmptyEntries); try { var result = commandInterpreter.InterpretCommand(input); writer.WriteLine(result); } catch (InvalidOperationException ioe) { writer.WriteLine(ioe.Message); } catch (ArgumentException ae) { writer.WriteLine(ae.Message); } } }
public void Run() { writer.WriteLine(OutputMessages.LibraryManagementHome); string command = String.Empty; while ((command = reader.ReadLine()) != "end") { try { IExecutable commandResult = commanInterpreter.InterpretCommand(command); MethodInfo method = typeof(IExecutable).GetMethods().First(); try { string result = (string)method.Invoke(commandResult, null); writer.WriteLine(result); } catch (TargetInvocationException tie) { throw tie.InnerException; } } catch (ArgumentException ae) { writer.WriteLine(ae.Message); } catch (NotImplementedException nie) { writer.WriteLine(nie.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; if (string.IsNullOrWhiteSpace(commandName)) { continue; } var command = interpreter.InterpretCommand(data, commandName); string result = command.Execute(); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; IExecutable instance = commandInterpreter .InterpretCommand(data, commandName); try { MethodInfo method = typeof(IExecutable).GetMethods().First(); string result = method.Invoke(instance, null).ToString(); Console.WriteLine(result); } catch (TargetInvocationException e) { throw e.InnerException; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; var commandInstance = commandInterpreter.InterpretCommand(data, commandName); var method = commandInstance .GetType() .GetMethod("Execute", BindingFlags.Instance | BindingFlags.Public); try { var result = (string)method.Invoke(commandInstance, null); Console.WriteLine(result); } catch (TargetInvocationException ex) { throw ex.InnerException; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; IExecutable command = commandInterpreter.InterpretCommand(data, commandName); MethodInfo method = typeof(IExecutable).GetMethods().First(); try { string result = (string)method.Invoke(command, null); //Execute do not need parammeters Console.WriteLine(result); } catch (TargetInvocationException e) { throw e.InnerException; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; //string result = InterpredCommand(data, commandName); IExecutable command = commandInterpreter.InterpretCommand(data, commandName); // Намираме метода на този клас - в случая е само един: MethodInfo method = typeof(IExecutable).GetMethods().First(); try { string result = (string)method.Invoke(command, null); Console.WriteLine(result); } catch (TargetInvocationException e) { throw e.InnerException; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; IExecutable command = commandInterpreter.InterpretCommand(data, commandName); var method = typeof(IExecutable).GetMethod("Execute"); try { var res = method.Invoke(command, new object[] { }); Console.WriteLine(res); } catch (Exception) { throw new ArgumentException("No such units in repository."); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = reader.ReadLine(); string result = commandInterpreter.InterpretCommand(input); this.writer.WriteLine(result); if (input.StartsWith("Shutdown")) { return; } } catch (Exception e) when(e is HarvesterNotRegisteredException || e is ProviderNotRegisteredException || e is InvalidSystemModeException || e is InvalidHarvesterTypeException || e is InvalidProviderTypeException || e is TargetInvocationException) { this.writer.WriteLine(e.InnerException.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] dataArgs = input.Split(';'); string commandName = dataArgs[0]; string[] data = dataArgs.Skip(1).ToArray(); IExecutable command = commandInterpreter.InterpretCommand(data, commandName); MethodInfo method = typeof(IExecutable).GetMethods().First(); try { method.Invoke(command, null); } catch (TargetInvocationException e) { throw e.InnerException; } } catch (Exception e) { //Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; IExecutable execute = commandInterpreter .InterpretCommand(data, commandName); string result = execute.Execute(); Console.WriteLine(result); //Console.WriteLine(execute); } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { string command; while ((command = this.reader.ReadLine()) != "END") { var commandTokens = command.Split(';'); var commandName = commandTokens[0]; var commandArgs = commandTokens.ToList().Skip(1).ToArray(); try { var commandInstance = commandInterpreter.InterpretCommand(commandName, commandArgs); var result = commandInstance.Execute(); this.writer.WriteLine(result); } catch (InvalidOperationException ioe) { this.writer.WriteLine(ioe.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); var instance = commandInterpreter.InterpretCommand(data); var type = typeof(IExecutable); try { var method = type.GetMethod("Execute"); var res = method.Invoke(instance, new object[] { }); Console.WriteLine(res); } catch (Exception ex) { Console.WriteLine(ex.InnerException.Message); //throw new ArgumentException("No such units in repository"); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(); string commandName = data[0]; IExecutable command = interpreter.InterpretCommand(data, commandName); var assembly = Assembly.GetExecutingAssembly(); var type = assembly.GetTypes().FirstOrDefault(t => t.Name.ToLower() == commandName + "command"); var method = type.GetMethod("Execute"); Console.WriteLine((string)method.Invoke(command, new object[] { })); } catch (Exception e) { Console.WriteLine(e.Message); } } }
public void Run() { while (true) { string[] commandArgs = Console.ReadLine().Split(';'); string result = commandInterpreter.InterpretCommand(commandArgs); if (result != null) { Console.WriteLine(result); } } }
public void Run() { bool isRunning = true; while (isRunning) { string inputLine = this.reader.ReadLine(); IList <string> arguments = this.parseInput(inputLine); var result = commandInterpreter.InterpretCommand(arguments); this.writer.WriteLine(result); isRunning = !this.ShouldEnd(inputLine); } }
public static void ReadInput(ICommandInterpreter interpreter) { string input; while ((input = Console.ReadLine()) != "END") { var cmdArgs = input.Split(";"); string command = cmdArgs[0]; cmdArgs = cmdArgs.Skip(1).ToArray(); var result = interpreter.InterpretCommand(cmdArgs, command); result.Execute(); } }
public void Run() { while (true) { try { string[] data = Console.ReadLine().Split(';'); string commandName = data[0]; IExecutable command = commandInterpreter.InterpretCommand(data, commandName); command.Execute(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public void Run() { while (true) { try { string input = Console.ReadLine(); string[] data = input.Split(';'); string commandName = data[0]; string[] commandData = data.Skip(1).ToArray(); IExecutable result = commandInterpreter.InterpretCommand(commandName, commandData); result.Execute(); } catch (Exception e) { //throw new Exception(e.Message); } } }
public void Run() { string input = Console.ReadLine(); while (input != "System Shutdown!") { string[] data = input.Split('@'); string commandName = data[0].Trim(':'); string[] parameters = new string[data.Length - 1]; for (int i = 1; i < data.Length; i++) { parameters[i - 1] = data[i]; } Console.WriteLine(interpreter.InterpretCommand(commandName, parameters)); input = Console.ReadLine(); } }
public void Run() { while (true) { try { var input = Console.ReadLine(); var data = input.Split(); var commandName = data[0]; var command = commandInterpreter.InterpretCommand(data, commandName); var result = command.Execute(); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine(e.Message); } } }