Ejemplo n.º 1
0
        public bool TryParse(string argument, out PromptQuery prompt)
        {
            prompt = null;
            string key      = null;
            string question = null;
            string answer   = null;

            var remaining = argument;

            if (remaining.Contains(":"))
            {
                var parts = remaining.Split(new[] { ":" }, 2, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length < 2)
                {
                    return(false);
                }
                key       = parts[0];
                remaining = parts[1];
            }

            string parsedQuestion;
            string parsedAnswer;

            if (TryParseQA(remaining, out parsedQuestion, out parsedAnswer))
            {
                question = parsedQuestion;
                answer   = parsedAnswer;
            }
            else
            {
                question = remaining;
                answer   = null;
            }

            prompt = new PromptQuery(question, answer, key);
            return(true);
        }
Ejemplo n.º 2
0
 public void AddAnswer(PromptQuery prompt, string answer) => _answers[prompt.Key] = answer;