作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个表单流对话框,其中将以下问题定义为枚举
public enum PreviousOwnerOptions
{
[Describe("Owned from new")]
[Terms("0", "new", ".*[O|o]wned from new")]
OwnedFromNew = 0,
[Terms("1", "One")]
One,
[Terms("2", "Two")]
Two,
[Terms("3", "Three")]
Three,
[Terms("4", "Four")]
Four,
[Terms("5", "Five")]
Five,
[Terms("6", "Six")]
Six,
[Describe("More than six")]
[Terms(".*More than six", "more")]
MoreThanSix
}
Terms
属性会负责澄清吗?
最佳答案
这是由于两件事的结合而发生的。
首先,您尝试在看似不可为空的字段上使用 0 Enum 值。在这种情况下,0 值保留为空值。来自 formflow docs page :
Any of the data types may be nullable, which you can use to model that the field does not have a value. If a form field is based on an enumeration property that is not nullable, the value 0 in the enumeration represents null (i.e., indicates that the field does not have a value), and you should start your enumeration values at 1. FormFlow ignores all other property types and methods.
[Terms("1", "One")]
默认情况下,formflow 会尝试将这些值与正确的枚举对齐。所以我认为正在发生的是,它让您选择示例中使用的“3”,因为 3 是您的术语之一
[Terms("3", "Three")]
它为您提供了这些选择。但在零索引枚举值中,由于0被保留,实际枚举值
[Terms("2", "Two")] Two,
是 3。所以它不知道你的意思。
public enum PreviousOwnerOptions
{
[Terms("1", "One")]
One=1,
[Terms("2", "Two")]
Two,
[Terms("3", "Three")]
Three,
[Terms("4", "Four")]
Four,
[Terms("5", "Five")]
Five,
[Terms("6", "Six")]
Six,
[Describe("More than six")]
[Terms(".*More than six", "more")]
MoreThanSix,
[Describe("Owned from new")]
[Terms("new", ".*[O|o]wned from new")]
OwnedFromNew
}
关于botframework - Formflow 机器人与枚举答案位置与答案文本混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51058051/
我是一名优秀的程序员,十分优秀!