无法从 'method group' 转换为 'ResumeAfter<object>'
Cannot convert from 'method group' to 'ResumeAfter<object>'
我正在尝试根据 Luis 意图创建一个子对话框,以从用户那里收集更多信息。但是,我在 context.Call
的第二个参数上收到无法从 'method group' 转换为 'ResumeAfter<object>' 的错误消息
[LuisIntent("Login")]
public async Task LoginIntent(IDialogContext context, LuisResult result)
{
var serverdialog = new ServerDialog();
await context.Call(serverdialog, ResumeAfterServerDialog); //error here
}
private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<string> serverName)
{
this.serverAddress = await serverName;
await context.PostAsync($"you've entered {this.serverAddress}");
context.Wait(MessageReceived);
}
服务器对话框 class 是
[Serializable]
public class ServerDialog : IDialog<object>
{
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("Enter your server's name (example: 10.10.10.52)");
context.Wait(ReceiveServerDialog);
}
public async Task ReceiveServerDialog(IDialogContext context, IAwaitable<IMessageActivity> result)
{
IMessageActivity message = await result;
context.Done(message.Text);
}
}
我找到了一个解释:
MessageReceived 的第二个参数的类型可能是 IAwaitable,但是您需要一个带有 IAwaitable 的第二个参数的方法,例如,如果您将 null 作为结果值传递并且子对话框的类型是IDialog.
但是我无法理解这一点。
你的对话框实现了 IDialog<object>
但你的 ResumeAfter<T>
方法 ReceiveServerDialog
是一个期待的字符串(在 IAwaitable<string> serverName
参数中)
更改对话框以实现 IDialog<string>
或将 ReceiveServerDialog
方法更改为
private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<object> serverName)
我正在尝试根据 Luis 意图创建一个子对话框,以从用户那里收集更多信息。但是,我在 context.Call
的第二个参数上收到无法从 'method group' 转换为 'ResumeAfter<object>' 的错误消息[LuisIntent("Login")]
public async Task LoginIntent(IDialogContext context, LuisResult result)
{
var serverdialog = new ServerDialog();
await context.Call(serverdialog, ResumeAfterServerDialog); //error here
}
private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<string> serverName)
{
this.serverAddress = await serverName;
await context.PostAsync($"you've entered {this.serverAddress}");
context.Wait(MessageReceived);
}
服务器对话框 class 是
[Serializable]
public class ServerDialog : IDialog<object>
{
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("Enter your server's name (example: 10.10.10.52)");
context.Wait(ReceiveServerDialog);
}
public async Task ReceiveServerDialog(IDialogContext context, IAwaitable<IMessageActivity> result)
{
IMessageActivity message = await result;
context.Done(message.Text);
}
}
我找到了一个解释:
MessageReceived 的第二个参数的类型可能是 IAwaitable,但是您需要一个带有 IAwaitable 的第二个参数的方法,例如,如果您将 null 作为结果值传递并且子对话框的类型是IDialog.
但是我无法理解这一点。
你的对话框实现了 IDialog<object>
但你的 ResumeAfter<T>
方法 ReceiveServerDialog
是一个期待的字符串(在 IAwaitable<string> serverName
参数中)
更改对话框以实现 IDialog<string>
或将 ReceiveServerDialog
方法更改为
private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<object> serverName)