Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
 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;
     }
 }