装饰示范田与资源文件的元数据 [英] Decorate model fields with metadata from resource file

查看:145
本文介绍了装饰示范田与资源文件的元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我想通过让他们搬到别的地方去,这样我的code相可读分开我的属性装饰(3%至4场)。
  • 也通过一些属性的参数应该来自资源文件。 例如: [必需的(无法继续,而无需输入* FIELD_NAME *)] 我只需要 [必需]
  • I would like to separate my attribute decoration(3-4 per field) by having them someplace else so that my code looks readable.
  • Also the arguments passed to some attributes should come from a resource file. EG:[Required("Cannot proceed without entering *field_Name*")] I need just [Required]

这个问题(关于这一点我无法抗拒提供赏金)可能的复制:<一href="http://stackoverflow.com/questions/3260748/default-resource-for-data-annotations-in-asp-net-mvc">Default资源数据注解。

Possible duplicate of this question(on which i couldn't resist offering a bounty) : Default resource for data annotations.

推荐答案

对于第一个问题,也许你可以尝试使用的流利的验证的。您可以通过以下的这些说明

For the first question, maybe you could try using Fluent Validation. You can hook it up to MVC by following these instructions.

对于第二个问题,我已经张贴一个答案在这里:<一href="http://stackoverflow.com/questions/3260748/default-resource-for-data-annotations-in-asp-net-mvc">Default资源在ASP.NET MVC 数据说明

For the second question, I've posted an answer here: Default resource for data annotations in ASP.NET MVC

这篇关于装饰示范田与资源文件的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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