MVC3 - 在哪里放置自定义属性类 [英] MVC3 - Where to place custom attribute classes

查看:513
本文介绍了MVC3 - 在哪里放置自定义属性类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我钻研自定义验证属​​性,并很想知道别人是如何构建的项目。你在哪里通常存储自定义属性?

I am delving into custom validation attributes and am curious to know how others structure the projects. Where do you typically store custom attributes?

我首先想到的是简单地创建一个新的文件夹,并用它做。

My first thought was to simply create a new folder and be done with it.

有什么建议?

推荐答案

我用2个不同的方法。


  1. 建立一个共同的类库来存储将在很多MVC应用程序使用常见的验证。然后从你的MVC应用程序中引用这个库。您可以使用 http://dataannotationsextensions.org/ 查看源$ C ​​$ c。关于如何设置这个项目。

  1. Set up a common Class Library to store common validation that will be used on many MVC applications. Then reference this library from your MVC application. You can use http://dataannotationsextensions.org/ to view the source code on how to setup this project.

将它们放在文件夹由达林的建议。此文件夹将用于存储自定义验证。如果你的应用程序被用来保持高尔夫杆数自定义验证只对应用程序可能有事情做一个差点计算或一些具体的事情。

Place them in folders as suggested by Darin. This folder would be used to store custom validation. If you app was used to keep golf scores a custom validation only to the application could have something to do with a handicap calculation or something specific.

谢谢,

这篇关于MVC3 - 在哪里放置自定义属性类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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