Ejemplo n.º 1
0
        internal void RemoveUnusedTemplateFiles()
        {
            var solutionItems              = _vsManager.GetAllSolutionItems();
            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();
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 3
0
        private void ProjectSync(ProjectItem templateProjectItem, IEnumerable <FileBuilder.OutputFile> keepFileNames)
        {
            var groupedFileNames = from f in keepFileNames
                                   group f by new { f.ProjectName, f.FolderName }
            into l
                select new
            {
                ProjectName = l.Key.ProjectName,
                FolderName  = l.Key.FolderName,
                FirstItem   = l.First(),
                OutputFiles = l
            };

            _templatePlaceholderList.Clear();

            foreach (var item in groupedFileNames)
            {
                ProjectItem pi = VsManager.GetTemplateProjectItem(templateProjectItem.DTE, item.FirstItem, templateProjectItem);
                ProjectSyncPart(pi, item.OutputFiles);
                if (UseAutoFormatting)
                {
                    FormatDocument(pi.ProjectItems);
                }
                if (pi.Name.EndsWith("txt4"))
                {
                    _templatePlaceholderList.Add(VsManager.GetProjectItemFullPath(pi));
                }
            }

            // clean up
            bool hasDefaultItems = groupedFileNames.Any(f => string.IsNullOrEmpty(f.ProjectName) && string.IsNullOrEmpty(f.FolderName));

            if (hasDefaultItems == false)
            {
                ProjectSyncPart(templateProjectItem, new List <OutputFile>());
            }
        }