[VS2010 T4]是否可以获取当前项目的名称? [英] [VS2010 T4] Any way to obtain name of the current project?
本文介绍了[VS2010 T4]是否可以获取当前项目的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好!有一个模板可以遍历解决方案中的所有文件,并为其中的一些文件生成帮助器.目前,引导程序部分看起来像
Hello! There's a template which traverses all files in solution and generates helpers for some of them. Currently the bootstrap part looks like
string projectName = "SomeProject";
IServiceProvider serviceProvider = (IServiceProvider)this.Host;
DTE dte = (DTE)serviceProvider.GetService(typeof(DTE));
Project currentProject = dte.Solution.Projects.Cast<Project>().Single(p=>p.Name == projectName);
Visit(currentProject);
现在,我需要创建可重复使用的模板,因此,我需要一种无需对当前项目进行硬编码即可获取其名称的方法.有什么建议吗?
Now I'm need to create reusable template, so, I need a way to obtain the name of the current project without hardcoding it. Any suggestions?
谢谢!
推荐答案
Dte.ActiveSolutionProjects应该为您提供所需的东西.
Dte.ActiveSolutionProjects should give you what you need.
这篇关于[VS2010 T4]是否可以获取当前项目的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文