Exemple #1
0
 public async Task<string> AskAsync(Question question)
 {
     var b = new WriteOnceBlock<string>(s => s);
     question.answerBlock = b;
     // TODO: handle if buffer refuses message? If task.Result is false
     var task = await buf.SendAsync(question);
     return await b.ReceiveAsync();
 }
 public async Task<string> AskAsync(Question question) => await Task.Run(() =>
 {
     output.WriteLine(question.Preamble);
     var match = false;
     string response = null;
     while (!match)
     {
         output.WriteLine(question.Query);
         response = input.ReadLine()?.Trim();
         match = question.Answers.Any(a => a.EqualsOrdIgnoreCase(response));
         if (!match)
         {
             var answers = string.Join(", ", question.Answers);
             output.WriteLine($"\nAnswer must be one of these values: {answers}");
         }
     }
     return response;
 });
Exemple #3
0
 public Task<string> AskAsync(Question question)
 {
     return Task.FromResult(Answer);
 }
 public Task<string> AskAsync(Question question)
 {
     return null;
 }