public static void Main(string[] args) { Build(); var line = ""; while ((line = Console.ReadLine()) != "exit") { var words = new Regex("\\s").Split(line); var cmd = new CommandIn(words[0], words.Skip(1).ToArray()); cmd.RequestInDefaultContext(); switch (cmd.Feedback) { case CommandInResult.UnknownCommand: Console.WriteLine("Unknown Command."); break; case CommandInResult.Forwarded: Console.WriteLine("Command is being processed."); break; case CommandInResult.Error: Console.WriteLine("Error: " + cmd.FeedbackText); break; default: break; } } }
private void OnCommandIn(CommandIn obj) { try { if (commandKnowledge.ContainsKey(obj.Command)) { var thread = new Thread(() => { commandKnowledge[obj.Command](obj.CommandParameter); }); thread.Start(); obj.Feedback = CommandInResult.Forwarded; } else { obj.Feedback = CommandInResult.UnknownCommand; } } catch (Exception e) { obj.Feedback = CommandInResult.Error; obj.FeedbackText = e.Message; } }