예제 #1
0
        private bool IsValidInput(Module source, string s)
        {
            Command  cmd;
            Response rsp;

            if ((Response.IsResponse(s) && Response.TryParse(s, source, out rsp)) ||
                Command.IsCommand(s) && Command.TryParse(s, source, out cmd))
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
        private void Inject()
        {
            Module   source;
            Command  cmd;
            Response rsp;

            string[]     inputs;
            HistoryToken token;

            if ((source = (Module)cbModules.SelectedItem) == null)
            {
                return;
            }

            inputs = BulkMode ?
                     txtMessage.Text.Split(separators, StringSplitOptions.RemoveEmptyEntries) :
                     new string[] { txtMessage.Text.Trim() };

            foreach (string input in inputs)
            {
                //blackboard.Inject(source.Name + " " + input);
                token = null;
                if (Response.IsResponse(input) && Response.TryParse(input, source, out rsp))
                {
                    token = new HistoryToken(rsp);
                }
                else if (Command.IsCommand(input) && Command.TryParse(input, source, out cmd))
                {
                    token = new HistoryToken(cmd);
                }
                if (token == null)
                {
                    blackboard.Inject(source.Name + " " + input);
                    continue;
                }

                blackboard.Inject(token.StringToInject);
                AddHystoryToken(token);
            }
            txtMessage.Clear();
        }