自定义 Visual Studio 上下文菜单
我想使用 T4 模板自动创建一些代码,但我想添加一个用户输入框(例如,询问名称),类似于右键单击某个对象时的 MVC3“添加视图”/“添加控制器”对话框特定文件夹。这对于纯 T4 模板是否可行,或者是否会导致编写 VS 插件 DLL?如果涉及编写 DLL,我可以将其放入项目引用中并在每个项目中使用它,还是必须在每台计算机上单独注册?
I want to use T4 templates to automatically create some code but I want to add a user input box (to ask for a name, for example) similar to the MVC3 "Add View" / "Add Controller" dialog when you right click on a specific folder. Is this possible with pure T4 templates or is it going to result in a writing a VS plugin DLL? If it involves writing a DLL can I just plop that into the projects reference and use it per-project or does it have to be registered individually on each machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设法弄清楚了。我可能应该先尝试一下。只需将所需的导入添加到您的 T4 模板:
然后以编程方式创建带有标签、输入框和按钮的表单。在 DialogResult.OK(例如)上,只需读取输入值并用它执行您需要的操作。工作完美:-)
Managed to figure it out. I probably should of tried this first. Just add the required imports to your T4 template:
and then create a form programmatically with a label, input box and button. On DialogResult.OK (for example) just read the input value and do what you need with it. Works perfectly :-)