private void LoadTypesFromSolution(Dictionary <string, Type> availableTypes, IServiceProvider provider, Project dteProject) { IVsSolution solution = provider.GetService(typeof(SVsSolution)) as IVsSolution; if (solution != null) { List <EnvDTE.Project> projectList = new List <Project>(); HierarchyNode solutionHierarchy = new HierarchyNode(solution); solutionHierarchy.RecursiveForEach(delegate(HierarchyNode child) { // recurse if this node is a Solution Folder if (child.TypeGuid != Microsoft.Practices.VisualStudio.Helper.Constants.SolutionFolderGuid) { // If this is a project add it to the list EnvDTE.Project childProject = child.ExtObject as EnvDTE.Project; if (childProject != null) { projectList.Add(childProject); } } } ); LoadTypesFromProjects(projectList, availableTypes, provider, dteProject); } }
public void RecursiveForEachWalksAllChildrenAndParent() { int children = 3; MockVSHierarchy hierarchy = new MockVSHierarchy(children); MockVsSolution solution = new MockVsSolution(hierarchy); HierarchyNode node = new HierarchyNode(solution); int i = 0; node.RecursiveForEach(delegate(HierarchyNode child) { Trace.WriteLine(child.Name); i++; }); Assert.AreEqual((children + 1), i, "Incorrect number of nodes walked"); }
private void TraverseHierarchyNode(HierarchyNode node) { node.RecursiveForEach(delegate(HierarchyNode child) { // recurse if this node is a Solution Folder if (child.TypeGuid != SolutionFolderGuid) { // If this is a project, add the mapping if (child.ExtObject is EnvDTE.Project) { Collection <Role> roles = GetRoles(child.ExtObject as Project); if (child.ProjectGuid != Guid.Empty) { ProjectMappingEntry mapping = new ProjectMappingEntry(child.ProjectGuid, ProjectPath, roles, child.Name); manager.AddProjectMappingEntry(mappingTableName, mapping); this.Trace(Resources.MappingTableAddedMessage, TraceEventType.Information, child.Name, mappingTableName, roles.Count); } } } }); }
private void LoadTypesFromSolution(Dictionary<string, Type> availableTypes, IServiceProvider provider, Project dteProject) { IVsSolution solution = provider.GetService(typeof(SVsSolution)) as IVsSolution; if (solution != null) { List<EnvDTE.Project> projectList = new List<Project>(); HierarchyNode solutionHierarchy = new HierarchyNode(solution); solutionHierarchy.RecursiveForEach(delegate(HierarchyNode child) { // recurse if this node is a Solution Folder if (child.TypeGuid != Microsoft.Practices.VisualStudio.Helper.Constants.SolutionFolderGuid) { // If this is a project add it to the list EnvDTE.Project childProject = child.ExtObject as EnvDTE.Project; if (childProject != null) projectList.Add(childProject); } } ); LoadTypesFromProjects(projectList, availableTypes, provider, dteProject); } }
private void TraverseHierarchyNode(HierarchyNode node) { node.RecursiveForEach(delegate(HierarchyNode child) { // recurse if this node is a Solution Folder if (child.TypeGuid != SolutionFolderGuid) { // If this is a project, add the mapping if (child.ExtObject is EnvDTE.Project) { Collection<Role> roles = GetRoles(child.ExtObject as Project); if (child.ProjectGuid != Guid.Empty) { ProjectMappingEntry mapping = new ProjectMappingEntry(child.ProjectGuid, ProjectPath, roles, child.Name); manager.AddProjectMappingEntry(mappingTableName, mapping); this.Trace(Resources.MappingTableAddedMessage, TraceEventType.Information, child.Name, mappingTableName, roles.Count); } } } }); }