public string ExecuteCommand(ClientViewModel clientViewModel, string[] arguments)
 {
     try {
         var commandName = arguments.First();
         var command = _commandLines.FirstOrDefault(x => string.Equals(x.Name, commandName, StringComparison.CurrentCultureIgnoreCase));
         if (command == null) {
             return "Unknown command.";
         }
         else {
             var parameters = Enumerable.Empty<string>();
             if (arguments.Length > 1) {
                 parameters = arguments.Skip(1);
             }
             return clientViewModel.ExecuteCommand(command, parameters);
         }
     }
     catch (Exception ex) {
         return ex.Message;
     }
 }
Esempio n. 2
0
 public string ExecuteCommand(ClientViewModel clientViewModel, string[] arguments)
 {
     try {
         var commandName = arguments.First();
         var command     = _commandLines.FirstOrDefault(x => string.Equals(x.Name, commandName, StringComparison.CurrentCultureIgnoreCase));
         if (command == null)
         {
             return("Unknown command.");
         }
         else
         {
             var parameters = Enumerable.Empty <string>();
             if (arguments.Length > 1)
             {
                 parameters = arguments.Skip(1);
             }
             return(clientViewModel.ExecuteCommand(command, parameters));
         }
     }
     catch (Exception ex) {
         return(ex.Message);
     }
 }