Botframework 用FieldReflector验证场

Botframework 用FieldReflector验证场,botframework,formflow,Botframework,Formflow,我有一个属性,由于前面的问题,我禁用了它 .Field(new FieldReflector<UploadDocumentForm>(nameof(UploadDocumentForm.StatusContent)) .SetActive((state) => false)) .Field(新的FieldReflector(名称)(UploadDocumentForm.StatusContent)) .SetActive((状态)=>false)) 但是,通过另一个

我有一个属性,由于前面的问题,我禁用了它

.Field(new FieldReflector<UploadDocumentForm>(nameof(UploadDocumentForm.StatusContent))
    .SetActive((state) => false))
.Field(新的FieldReflector(名称)(UploadDocumentForm.StatusContent))
.SetActive((状态)=>false))
但是,通过另一个选项,我可能需要对该字段进行验证,并根据用户选择的内容向用户发送消息。有可能吗? 我不知道使用“FieldReflector”后字段是否有效

提前感谢

是的,您可以利用
FieldReflector
类来实现您的需求

如果需要在用户验证失败时提示用户,可以利用
ValidateResult
的属性。如果希望始终向用户发送消息,可以利用
FormBuilder
message()

以下是代码片段:

...
private static string msg = "default";
...
...
.Field(new FieldReflector<Classification>(nameof(Choice))
                        .SetValidate(async (state, value) => {
                            var selection = (<ClassName>)value;
                            bool isValid = (int)selection > 2;
                            msg = $"Select Value is {selection}";
                            ValidateResult result = new ValidateResult
                            {
                                IsValid = isValid,
                                Value = selection,
                            };
                            if (!isValid)
                            {
                                result.Feedback = msg;
                            }
                            return result;
                        })
                       )
                   .Message(msg)
。。。
私有静态字符串msg=“default”;
...
...
.Field(新的FieldReflector(名称(选择))
.SetValidate(异步(状态、值)=>{
var选择=()值;
bool isValid=(int)选择>2;
msg=$“选择值为{selection}”;
ValidateResult结果=新的ValidateResult
{
IsValid=IsValid,
值=选择,
};
如果(!isValid)
{
结果:反馈=味精;
}
返回结果;
})
)
.Message(msg)