开发者

VS 2010 SDK. Templates

If you try and create an MVC3 project, you’ll see that you have an ability to add Controller or View with rc. And context menu you get on Controller folder with rc will magically suggest to add Controller while on the Views you’ll be suggested to add V开发者_如何学Goiew.

As I understand, to achieve this I need to bind somehow 4 things. Project template, Item template, T4 templates (used to generate Contoller class or View) and a wizard lieing between T4 and Intem template (within WizardExtension section in Item Template).

How to have all these goods MVC3 project has for a custom template? I couldn’t dig how to bind those 4 things. Maybe somewhere in msdn there is an article I missed (I looked at “Visual Studio Templates” but that did not help much in understanding how to get to my goal). Or maybe someone had a nice experience doing something similar.

P.s. I’m using VS 2010 SDK SP1 Experimental Instance


The functionality you see in MVC 3 projects is implemented as follows:

MVC 3 projects are specially marked using an MVC 3 project type GUID (you can see it in a project's csproj file). The presence of this GUID triggers Visual Studio to load the MVC Tools VSPackage. The VSPackage is responsible for adding commands and other UI elements (e.g. the Add View button) that become active depending on what you select in your project. These commands invoke dialogs to gather user input which is then used to instantiate a T4 template host and invoke the template.

The VS item templates and template wizards only come into play when you try to add a view using the Add New Item dialog.

Overall creating a VSPackage is a pretty complicated subject. A good place to get started is here: http://msdn.microsoft.com/en-us/vstudio/ff677564.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜