使用 ActiveSolutionProjects 返回项目的顺序是什么?
我在项目模板向导中使用此代码。
DTE dte = project.DTE;
VSProject vsProj = (VSProject)project.Object;
Array projects = (Array)dte.ActiveSolutionProjects;
Project activeProject = (Project)projects.GetValue(0);
但我很好奇项目返回的顺序是什么? 上面的代码在项目创建后立即运行,
public void ProjectFinishedGenerating(Project project)
项目按什么顺序返回? 我的目标是获取最新的项目,GetValue(0)
可以吗?
Im using this code, inside a project template wizard.
DTE dte = project.DTE;
VSProject vsProj = (VSProject)project.Object;
Array projects = (Array)dte.ActiveSolutionProjects;
Project activeProject = (Project)projects.GetValue(0);
But im curious in what order the projects are returned?
The code above is running just after the project is created, in the
public void ProjectFinishedGenerating(Project project)
In what order does the projects get returned?
My goal is to get the newest project, will GetValue(0)
do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不久前看过这个,顺序似乎是不确定的。
GetValue(0) 是活动项目,可能不是最新项目。
要查找最新的,您需要使用文件戳来遍历项目
在项目文件(如果已保存)上加上未保存的文件的排名越高。
I looked at this a while back and the order seems to be non-determinstic.
GetValue(0) is the active project which might not be newest project.
To find the newested, you will need to traverse the projects using either the file stamp
on the project file (if saved) plus ranking non-saved ones higher as higher.