示例#1
0
文件: Engine.cs 项目: AndrewTheM/OOP
        public void Run()
        {
            while (true)
            {
                try
                {
                    string   input       = Console.ReadLine();
                    string[] data        = input.Split();
                    string   commandName = data[0];

                    if (string.IsNullOrWhiteSpace(commandName))
                    {
                        continue;
                    }

                    var    interpreter = new CommandInterpreter(repository, unitFactory);
                    var    command     = interpreter.InterpretCommand(data, commandName);
                    string result      = command.Execute();

                    Console.WriteLine(result);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
示例#2
0
 public void Run()
 {
     while (true)
     {
         try
         {
             string   input       = Console.ReadLine();
             string[] data        = input.Split();
             string   commandName = data[0];
             string   result      = commandInterpreter.InterpretCommand(data, commandName);
             Console.WriteLine(result);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }