如何在Botframework上检查对话框堆栈 [英] How can you inspect the Dialog Stack on Botframework

查看:78
本文介绍了如何在Botframework上检查对话框堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个反馈对话框,并希望使用IScorable从任何地方进入对话框,并键入"feedback"一词,并将我的FeedbackDialog推入堆栈.

在收集用户反馈时,我不希望出现这种情况.有没有办法确定我的FeedbackDialog是否已经在堆栈上?所以我不会不小心双按它吗?

解决方案

您可以像下面那样解决堆栈.首先,注册必要的模块:

private void RegisterTypes()
{
    var builder = new ContainerBuilder();
    builder.RegisterModule(new DialogModule());
    builder.RegisterModule(new ReflectionSurrogateModule());
    builder.RegisterModule(new DialogModule_MakeRoot());
    // necessary configurations
    // ...
}

然后,解决堆栈:

using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
{
    var stack = scope.Resolve<IDialogStack>();
}

stack.Frames中的

中,您可以在堆栈对话框中按顺序找到对话框列表(stack.Frames[0]在堆栈顶部).您可以使用FrameTarget属性(即stack.Frames[0].Target)找到对话框的名称.因此,您可以使用以下代码在堆栈中找到FeedbackDialog:

stack.Frames.Any(x=> x.Target.GetType().UnderlyingSystemType.Name == "FeedbackDialog")

I'm implementing a feedback dialog, and want to drop into the dialog from anywhere using an IScorable and key off the word "feedback" and push my FeedbackDialog onto the stack.

I don't want this behavior while collecting feedback from the user. Is there a way to determine if my FeedbackDialog is already on the stack? So I don't accidentally double push it?

解决方案

You can resolve the stack like the following. First, register the necessary modules:

private void RegisterTypes()
{
    var builder = new ContainerBuilder();
    builder.RegisterModule(new DialogModule());
    builder.RegisterModule(new ReflectionSurrogateModule());
    builder.RegisterModule(new DialogModule_MakeRoot());
    // necessary configurations
    // ...
}

After that, resolve the stack:

using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
{
    var stack = scope.Resolve<IDialogStack>();
}

in stack.Frames you can find the list of the dialogs in order of them in the stack dialog(stack.Frames[0] is on the top of the stack). You can find the name of the dialog using Target property of a Frame, i.e., stack.Frames[0].Target. Therefore, you can find the FeedbackDialog in the stack if it exists using the following code:

stack.Frames.Any(x=> x.Target.GetType().UnderlyingSystemType.Name == "FeedbackDialog")

这篇关于如何在Botframework上检查对话框堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆