c# – 当用户将字段名称作为值提交时,FormFlow禁用字段之间的切换

c# – 当用户将字段名称作为值提交时,FormFlow禁用字段之间的切换,第1张

概述我们在我们的机器人中使用FormFlow. FormFlow有一个功能,允许用户键入字段的名称,并切换到给定的字段.假设我们有这样的模型类 public class SampleModelClass { public string FirstField { get; set; } public string SecondField { get; set; } 我们在我们的机器人中使用FormFlow. FormFlow有一个功能,允许用户键入字段的名称,并切换到给定的字段.假设我们有这样的模型类

public class SampleModelClass    {        public string FirstFIEld { get; set; }        public string SecondFIEld { get; set; }    }

当要求用户输入FirstFIEld时,用户可能实际输入“first fIEld”,这导致再次询问FirstFIEld的问题.有没有办法禁用它并将“first fIEld”作为FirstFIEld的值?重命名FirstFIEld会起作用,但我们正在寻找更好的解决方案

解决方法

When the user is asked to enter FirstFIEld there is a possibility that the user can actually type “first fIEld” which results in asking the question for the FirstFIEld again. Is there any way to disable this and take “first fIEld” as the value of FirstFIEld? Renaming FirstFIEld would work,but we are looking for a better solution

您可以尝试使用Terms attribute(使用正则表达式)来定义用于将用户输入与字段或字段中的值匹配的术语列表,以下示例供您参考.

[Serializable]public class SampleModelClass{    [Terms(@"^[.*]$")]    public string FirstFIEld { get; set; }    [Terms(@"^[.*]$")]    public string SecondFIEld { get; set; }    public static IForm<SampleModelClass> BuildForm()    {        return new FormBuilder<SampleModelClass>()                .Message(async (state) => { return new PromptAttribute($"Welcome to the form bot!"); })                .Build();    }}

测试结果:

总结

以上是内存溢出为你收集整理的c# – 当用户将字段名称作为值提交时,FormFlow禁用字段之间的切换全部内容,希望文章能够帮你解决c# – 当用户将字段名称作为值提交时,FormFlow禁用字段之间的切换所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1233169.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存