-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathChoiceDialog.cs
More file actions
35 lines (33 loc) · 1008 Bytes
/
ChoiceDialog.cs
File metadata and controls
35 lines (33 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace MyBot
{
[Serializable]
public class ChoiceDialog : IDialog<string>
{
protected string msg;
protected List<string> opts = new List<string>();
public ChoiceDialog(string msg, IEnumerable<string> opts)
{
this.msg = msg;
foreach(var x in opts) { this.opts.Add(x); }
}
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync(msg);
var O = new PromptOptions<string>(msg, options: opts);
PromptDialog.Choice(context, ProcessResult, O);
}
private async Task ProcessResult(IDialogContext context, IAwaitable<object> result)
{
var res = await result;
context.Done((string)res);
}
}
}