ASP.NET MVC 2 - 实现自定义元数据和验证供应商 [英] ASP.NET MVC 2 - Implementing custom Metadata and Validator Providers

查看:174
本文介绍了ASP.NET MVC 2 - 实现自定义元数据和验证供应商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着 $ ASP.NET MVC 2 的对$ PVIEW 2的发布,我们现在有基类来实现我们对元数据和验证自己的自定义供应商。具体地讲,与 ModelMetadataProvider 和<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.modelvalidatorprovider%28VS.100%29.aspx\"相对=nofollow> ModelValidatorProvider

With the preview 2 release of ASP.NET MVC 2, we now have base classes to implement our own custom providers for metadata and validation. Specifically, with ModelMetadataProvider and ModelValidatorProvider.

有没有很多这些文件,但(昨天刚刚发布为 preVIEW ,所以我既不惊讶也不失望)。

There isn't a lot of documentation on these yet (just released yesterday as a preview, so I'm neither surprised nor disappointed).

有没有人得到的这两种工作的自定义实现?一个非常简单的例子(元数据和验证只是要求)将是巨大的!

Has anyone gotten custom implementations of either of these working? A very simple example (metadata and validator for just "Required") would be great!

也许很多人都有同样的想法,但我想用IronRuby的注入元数据,以及我在寻找任何实际的例子开始。

Perhaps a lot of people have the same idea, but I'd like to use IronRuby to inject the metadata, and I'm looking for any example to get started.

谢谢!

修改:听起来布拉德·威尔逊 xUnit.net 名声)有一些博客文章来为这个确切的事情!如果他不回答在这里,当那些职位准备好,我会创建一个链接一个答案。

Edit: Sounds like Brad Wilson (of xUnit.net fame) has some blog posts coming for this exact thing! If he doesn't answer here, I'll create an answer with links when those posts are ready.

EDIT2 :Sankarsan在百色在 CodingNDesign 也有关于这个问题 职位。 (目前ModelValidator)。这里包括以供将来参考。

Edit2: Sankarsan Bose over at CodingNDesign also has posts on the subject. (ModelValidator at the moment). Including here for future reference.

推荐答案

下面是一个例子验证供应商,使用企业库:

Here's an example validator provider, using Enterprise Library:

<一个href=\"http://bradwilson.typepad.com/blog/2009/10/enterprise-library-validation-example-for-aspnet-mvc-2.html\" rel=\"nofollow\">http://bradwilson.typepad.com/blog/2009/10/enterprise-library-validation-example-for-aspnet-mvc-2.html

元数据样本即将到来。

这篇关于ASP.NET MVC 2 - 实现自定义元数据和验证供应商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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