gpt4 book ai didi

c# - 无法从用法中推断方法 IDialogStack.Wait(ResumeAfter resume) 的类型参数

转载 作者:行者123 更新时间:2023-11-30 20:32:37 24 4
gpt4 key购买 nike

我正在使用 IDialog在我的机器人和我的一种方法中,由 Bot Framework 通过 context.Wait() 执行像往常一样有两个参数:

public async Task MainScreenSelectionReceived(IDialogContext context, 
IAwaitable<IMessageActivity> argument)

我想向此方法添加第三个可选参数,如果我直接从代码中的某个位置运行此方法(而不是当 Bot Framework 在 context.Wait() 之后运行它并接收消息时,我将指定该参数来自用户)。

所以我改方法如下:

public async Task MainScreenSelectionReceived(IDialogContext context, 
IAwaitable<IMessageActivity> argument,
bool doNotShowPrompt = false)

因此,现在所有 context.Wait调用显示为无效:

invalid context.wait

如果我从方法声明中删除第三个参数,该错误就会消失。

Visual Studio 显示的消息是:

The type arguments for method IDialogStack.Wait(ResumeAfter resume) cannot be inferred from the usage. Try specifying the type arguments explicitly.

我想这意味着我应该调用 context.Wait作为context.Wait<SOMETHING> , 但我不知道写什么来代替 SOMETHING .

最佳答案

进行重载,而不是添加可选参数。您的方法签名现在不再满足所需的委托(delegate)。

例如:

public async Task MainScreenSelectionReceived(IDialogContext context, 
IAwaitable<IMessageActivity> argument, bool doNotShowPrompt)
{
//Original code here
}

public async Task MainScreenSelectionReceived(IDialogContext context,
IAwaitable<IMessageActivity> argument)
{
return await MainScreenSelectionReceived(context, argument, false);
}

关于c# - 无法从用法中推断方法 IDialogStack.Wait<R>(ResumeAfter<R> resume) 的类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41134060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com