CSLA:对于每个特定类型的属性而不必为每个属性手动添加它,是否有可能为businessRule.add()添加它吗?
我创建了一个规则,用于检查日期时间是否有效。我想将其添加为每个DateTime属性的businesrule,以检查输入的用户输入是否有效,否则会发出警告。
现在,我必须在每个DateTime属性中添加每个类型属性的业务插曲,
BusinessRules.AddRule(new DateValidRule(BornDateProperty) { Severity = RuleSeverity.Warning });
BusinessRules.AddRule(new DateValidRule(LegitimationDateProperty) { Severity = RuleSeverity.Warning });
....
这将需要为Type DateTime的每个属性手动完成每个类。
有更好的方法可以做到这一点吗?
I have created a rule for checking if a DateTime is valid. I want to add this as a BusinesRule for every single DateTime Property to checks if the user input entered is valid and else give a warning.
Now I would have to add in every class the businessrules for each DateTime Property manually
BusinessRules.AddRule(new DateValidRule(BornDateProperty) { Severity = RuleSeverity.Warning });
BusinessRules.AddRule(new DateValidRule(LegitimationDateProperty) { Severity = RuleSeverity.Warning });
....
This will be needed to be done manually for every single class for every single Property of type DateTime.
Is there a better more efficient way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以使用
fieldmanager
属性访问注册属性列表,并循环通过它们。Yes, you can use the
FieldManager
property to access the list of registered properties and loop through them.