Esempio n. 1
0
        public virtual IEnumerable <T> GetItem <T>(bool recurcif = true) where T : SolutionItem
        {
            if (project != null && project.ProjectItems != null)
            {
                foreach (EnvDTE.ProjectItem s in project.ProjectItems)
                {
                    if (s == null)
                    {
                        continue;
                    }

                    SolutionItem fld = null;

                    if (s.SubProject is EnvDTE.Project proj)
                    {
                        fld = new Project(proj);
                    }

                    else if (s.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
                    {
                        fld = new FolderSolution(s as EnvDTE.Project);
                    }

                    else if (s.Kind == "{EA6618E8-6E24-4528-94BE-6889FE16485C}")
                    {
                        fld = new VirtualFolder(s as EnvDTE.Project);
                    }

                    else if (s.Kind == "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}")
                    {
                        fld = new ItemFolder(s);
                    }
                    else
                    {
                        //
                        fld = new Item(s);
                    }



                    if (fld is T)
                    {
                        yield return(fld as T);
                    }


                    if (recurcif)
                    {
                        foreach (SolutionItem i2 in fld.GetItem <T>(recurcif))
                        {
                            yield return(i2 as T);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public override IEnumerable <T> GetItem <T>(bool recurcif = true)
        {
            if (dte.Solution.Projects != null)
            {
                EnvDTE.DTE dte1 = dte ?? (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));

                foreach (EnvDTE.Project project in dte1.Solution.Projects)
                {
                    SolutionItem fld = null;

                    if (project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}" || project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
                    {
                        fld = new FolderSolution(project);
                    }

                    else if (project.Kind == "{EA6618E8-6E24-4528-94BE-6889FE16485C}")
                    {
                        fld = new VirtualFolder(project);
                    }

                    else
                    {
                        fld = new Project(project);
                    }

                    if (fld is T)
                    {
                        yield return(fld as T);
                    }

                    foreach (T item in fld.GetItem <T>(recurcif))
                    {
                        yield return(item);
                    }
                }
            }
        }