Visual Studio 2008 Add-in Verify that the hierarchy item is a solution folder

I have a visual addin studio written by a developer who is no longer in the company and has no idea how to debug it. But I want to add a function so that it can be overwritten in the solution folders.

It sounds simple, but I'm not sure if the api allows me to test this? Well, that should be because AnkhSVN and VisualSVN work great with solution folders.

StackOverflow I am asking for help on this issue.

thanks

Notes

-We use the solution folders to hide the “Projects of dependencies”, which are basically a list of links to projects that we probably do not need in a particular solution and they want to hide by default.

public class Connect : IDTExtensibility2, IDTCommandTarget
{

public void GetProjectLocations(DTE2 dte)
{

UIHierarchy UIH = dte.ToolWindows.SolutionExplorer;

try
{
     UIHierarchyItem UIHItemd = UIH.UIHierarchyItems.Item(1);
}
catch (Exception E)
{
  Debug.Write(E);
}

UIHierarchyItem UIHItem = UIH.UIHierarchyItems.Item(1);//this looks suspect to me

// Iterate through first level nodes.
for (int i = 1; i <= UIHItem.UIHierarchyItems.Count; i++)
{
  Project TempGeneralProjObj = dte.Solution.Item(i);  

  if (TempGeneralProjObj.Kind == PrjKind.prjKindCSharpProject)
  {
  }

}

}

}
+3
2

, Project , , Project.ProjectItems , . , , , , . , ProjectItem, , , find ProjectItem, , , .

.

if(project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
{
    // TODO: Do your thing
}

, , , ActiveReports , .

!

, , 100%, Macaw Blog.

, , , , ProjectItem , ProjectItem.SubProject.

, , , , , XML- , Stack. , , , .

        XElement rootNode = new XElement("Solution");
        rootNode.Add(new XAttribute("Name", _applicationObject.Solution.FullName));

        Stack<Project> projectStack = 
            new Stack<Project>(_applicationObject.Solution.Projects.Cast<Project>());

        while(projectStack.Count > 0)
        {
            var project = (Project)projectStack.Pop();
            var solutionItemName = "Project";

            if(project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
            {
                foreach(ProjectItem innerProject in project.ProjectItems)
                {
                    if(innerProject.SubProject != null)
                    {
                        projectStack.Push(innerProject.SubProject);
                    }
                }
                solutionItemName = "Folder";
            }

            var projectNode = new XElement(
                solutionItemName, 
                new XAttribute("Name", project.Name),
                new XAttribute("Kind", project.Kind)
                );
            rootNode.Add(projectNode);

            foreach(ProjectItem item in project.ProjectItems)
            {
                var itemNode = new XElement("Item", new XAttribute("Name", item.Name));
                projectNode.Add(itemNode);

                if(item.Properties == null)
                {
                    continue;
                }

                foreach(Property property in item.Properties)
                {
                    var propertyNode = new XElement(property.Name, property.Value);
                    itemNode.Add(propertyNode);
                }
            }
        }

, , , .

+4

Visual Studio, , . , , "" , , .

, ( ) , VS .

...

+1

Source: https://habr.com/ru/post/1705840/


All Articles