Пример #1
0
        internal void RemoveUnusedTemplateFiles()
        {
            var solutionItems              = VsManager.GetAllSolutionItems(_dte);
            var activeTemplateFullNames    = _placeholders.Values.Select(x => VsManager.GetProjectItemFullPath(x));
            var allHelperTemplateFullNames = solutionItems.Where(p => p.Name == VsManager.GetTemplatePlaceholderName(_templateProjectItem))
                                             .Select(VsManager.GetProjectItemFullPath);

            var delta = new HashSet <string>(allHelperTemplateFullNames.Except(activeTemplateFullNames));

            //Nalopen hier ligt misschien het issue
            var dirtyHelperTemplates = solutionItems.Where(p => delta.Contains(VsManager.GetProjectItemFullPath(p)));

            foreach (ProjectItem item in dirtyHelperTemplates)
            {
                if (item.ProjectItems != null)
                {
                    foreach (ProjectItem subItem in item.ProjectItems)
                    {
                        subItem.Remove();
                    }
                }

                item.Remove();
            }
        }
Пример #2
0
        private void CleanUpTemplatePlaceholders()
        {
            string[] activeTemplateFullNames    = _templatePlaceholderList.ToArray();
            string[] allHelperTemplateFullNames = _vsManager.GetAllSolutionItems()
                                                  .Where(p => p.Name == _vsManager.GetTemplatePlaceholderName(_templateProjectItem))
                                                  .Select(_vsManager.GetProjectItemFullPath)
                                                  .ToArray();

            var delta = allHelperTemplateFullNames.Except(activeTemplateFullNames).ToArray();

            var dirtyHelperTemplates = _vsManager.GetAllSolutionItems()
                                       .Where(p => delta.Contains(_vsManager.GetProjectItemFullPath(p)));

            foreach (ProjectItem item in dirtyHelperTemplates)
            {
                if (item.ProjectItems != null)
                {
                    foreach (ProjectItem subItem in item.ProjectItems)
                    {
                        subItem.Remove();
                    }
                }

                item.Remove();
            }
        }