使用MicrosoftBot的FormBuilder跳过确认步骤 [英] Skip confirmation step with MicrosoftBot's FormBuilder

查看:72
本文介绍了使用MicrosoftBot的FormBuilder跳过确认步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在填写表格之前,我不需要任何确认.但是,在 FormBuilder类的以下Build()方法中有一个 Confirm(这是您的选择吗?\ n {}")*.

I don't need any confirmation before completion of my form. However, in the following Build() method of the FormBuilder class there is a Confirm("Is this your selection?\n{}")*.

    public IForm<T> Build()
    {
        if (!_form._steps.Any((step) => step.Type == StepType.Field))
        {
            var paths = new List<string>();
            FormBuilder<T>.FieldPaths(typeof(T), "", paths);
            IFormBuilder<T> builder = this;
            foreach (var path in paths)
            {
                builder.Field(new FieldReflector<T>(path));
            }
            builder.Confirm("Is this your selection?\n{*}");
        }
        Validate();
        return this._form;
    }

调用build之后,有什么方法可以从生成的表单中删除此步骤吗?

Is there any way I can remove this step from my generated Form after calling build ?

            var form =  new FormBuilder<QuestionYourThinking>()
            .OnCompletionAsync(async (context, state) =>
            {
                await context.PostAsync("L'exercice est maintenant terminé. A bientot !");
            })
            .Build();

推荐答案

只需使用带有ActiveDelegate参数的重载并使方法处理程序返回false,那么将不会显示确认消息.

Just use the overload that take an ActiveDelegate parameter and make the method handler to return false then the confirmation message will not be shown.

return new FormBuilder<QuestionYourThinking>()
    .AddRemainingFields()
    .Confirm("No verification will be shown", state => false)
    .Message("L'exercice est maintenant terminé. A bientot !")
    .Build();

要发送消息,您可以使用流利的方法Message.

To send a message you can just use the fluent method Message.

这篇关于使用MicrosoftBot的FormBuilder跳过确认步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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