Exemplo n.º 1
0
        /// <summary>
        /// Removes old template placeholders from the solution.
        /// </summary>
        private void CleanUpTemplatePlaceholders()
        {
            string[] activeTemplateFullNames    = templatePlaceholderList.ToArray();
            string[] allHelperTemplateFullNames = VSHelper.GetAllSolutionItems(dte)
                                                  .Where(p => p.Name == VSHelper.GetTemplatePlaceholderName(templateProjectItem))
                                                  .Select(p => VSHelper.GetProjectItemFullPath(p))
                                                  .ToArray();

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

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

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

                item.Remove();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a list of helper templates from the log.
        /// </summary>
        /// <returns>List of generated helper templates.</returns>
        private string[] GetPreviousTemplatePlaceholdersFromLog()
        {
            string path            = Path.GetDirectoryName(_textTransformation.Host.ResolvePath(_textTransformation.Host.TemplateFile));
            string file1           = Path.GetFileNameWithoutExtension(_textTransformation.Host.TemplateFile) + ".txt";
            string contentPrevious = File.ReadAllText(Path.Combine(path, file1));

            var result = contentPrevious
                         .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                         .Select(x => x.Split(new[] { "=>" }, StringSplitOptions.RemoveEmptyEntries).First())
                         .Select(x => Regex.Replace(x, "//", String.Empty).Trim())
                         .Where(x => x.EndsWith(VSHelper.GetTemplatePlaceholderName(templateProjectItem)))
                         .ToArray();

            return(result);
        }