VS 2010 SDK.范本 [英] VS 2010 SDK. Templates

查看:153
本文介绍了VS 2010 SDK.范本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果尝试创建MVC3项目,则会看到您可以使用rc添加Controller或View.在带有rc的Controller文件夹中获得的上下文菜单会神奇地建议添加Controller,而在View上则建议您添加View.

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 View.

据我了解,要实现这一点,我需要以某种方式绑定4件事.项目模板,项目模板,T4模板(用于生成Contoller类或视图)以及位于T4和Intem模板之间的向导(在项目模板的WizardExtension部分中).

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).

如何将所有这些商品MVC3项目都具有一个自定义模板?我无法挖掘如何绑定这四件事.也许在msdn中的某个地方,我错过了一篇文章(我看着"

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.我正在使用VS 2010 SDK SP1实验实例

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

推荐答案

您在MVC 3项目中看到的功能实现如下:

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

MVC 3项目使用MVC 3项目类型GUID进行了特殊标记(您可以在项目的csproj文件中看到它).该GUID的存在会触发Visual Studio加载MVC工具VSPackage. VSPackage负责添加命令和其他UI元素(例如添加视图"按钮),这些命令和控件根据您在项目中选择的内容而变为活动状态.这些命令将调用对话框以收集用户输入,然后这些用户输入用于实例化T4模板主机并调用模板.

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.

仅当您尝试使用添加新项"对话框添加视图时,VS项模板和模板向导才会发挥作用.

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

总体而言,创建VSPackage是一个非常复杂的主题.入门的好地方是: http://msdn.microsoft.com/zh-我们/vstudio/ff677564 .

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.

这篇关于VS 2010 SDK.范本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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