Thanks, Reed; the article you linked got me far enough to get a proof of concept churned out in a couple minutes.
Since I feel it's related, here is the iteration and recursive means by which I collected the ProjectItems. I did this in DXCore, but the same idea applies to the raw Visual Studio SDK (DXCore is merely a nicer looking wrapper over the SDK). The 'Solution', 'Projects', 'Project', and 'ProjectItem' objects are right there in EnvDTE.
Setting Projects
EnvDTE.Solution solution = CodeRush.ApplicationObject.Solution;
EnvDTE.Projects projects = solution.Projects;
Iterating over the Projects to pull ProjectItems
var projects = myProjects.GetEnumerator();
while (projects.MoveNext())
{
var items = ((Project)projects.Current).ProjectItems.GetEnumerator();
while (items.MoveNext())
{
var item = (ProjectItem)items.Current;
//Recursion to get all ProjectItems
projectItems.Add(GetFiles(item));
}
}
Finally, The recursion I do for getting all ProjectItems in the active Solution
ProjectItem GetFiles(ProjectItem item)
{
//base case
if (item.ProjectItems == null)
return item;
var items = item.ProjectItems.GetEnumerator();
while (items.MoveNext())
{
var currentItem = (ProjectItem)items.Current;
projectItems.Add(GetFiles(currentItem));
}
return item;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…