在我的对话框中,我正在向用户发送提示对话框:
PromptOptions<string> options = new PromptOptions<string>($"some var" + var,
"invalid",
"Exceeded",
context.Activity.ChannelId.ToLower() == "skype" || context.Activity.ChannelId.ToLower() == "webchat" || context.Activity.ChannelId.ToLower() == "emulator" ?
new List<string>() { "yes","no","exit", } :
new List<string>() { "yes", "exit", },
3);
PromptDialog.Choice(context, this.OnOptionSelected, options);
和在OnOptionselectect的方法中:
private async Task OnOptionSelected(IDialogContext context, IAwaitable<string> result)
{
string optionSelected = await result;
switch (optionSelected)
{
case "yes":
CallMethod(**Param1**, true);
break;
case "no":
CallMethod(**Param1**, false);
break;
case "exit":
context.Call(new ExitDialog(), this.ResumeAfterOptionDialog);
break;
}
}
如何将param1传递到Onoptionselectectectectectectectemelectecteled方法,以便我可以使用它?
您将无法将参数传递给OnOptionselectectected方法。您无法更改ResumeAfter<T>
方法的签名。
进入此处的方法可能是利用botstate在PromptDialog
之前保存该值并在OnOptionSelected
方法上检索它们。
检查核心状态C#样本以了解有关如何使用botstate的更多信息。