private void GenerateSnippets(SnippetDirectory[] snippetDirectories, SnippetGeneratorSettings settings, Func <SnippetDirectory, bool> predicate) { IEnumerable <SnippetDirectory> items = snippetDirectories.Where(f => f.Language == Language); if (predicate != null) { items = items.Where(predicate); } snippetDirectories = items.ToArray(); if (snippetDirectories.Length > 0) { string source = items .Where(f => f.HasTag(KnownTags.AutoGenerationSource)) .Select(f => f.Path) .FirstOrDefault(); if (source != null) { string destination = items .Where(f => f.HasTag(KnownTags.AutoGenerationDestination)) .Select(f => f.Path) .FirstOrDefault(); if (destination != null) { var generator = new SnippetGenerator(settings); generator.GenerateSnippets(source, destination); } } } }
private static void Main(string[] args) { var settings = new GeneralSettings() { SolutionDirectoryPath = @"..\..\..\..\.." }; SnippetDirectory[] snippetDirectories = SnippetDirectory.LoadFromFile(@"..\..\SnippetDirectories.xml").ToArray(); CharacterSequence[] characterSequences = CharacterSequence.LoadFromFile(@"..\..\CharacterSequences.xml").ToArray(); LanguageDefinition[] languageDefinitions = LanguageDefinition.LoadFromFile(@"..\..\LanguageDefinitions.xml").ToArray(); CharacterSequence.SerializeToXml(Path.Combine(settings.ExtensionProjectPath, "CharacterSequences.xml"), characterSequences); SnippetGenerator.GenerateSnippets(snippetDirectories, languageDefinitions); SnippetGenerator.GenerateHtmlSnippets(snippetDirectories); SnippetGenerator.GenerateXamlSnippets(snippetDirectories); SnippetGenerator.GenerateXmlSnippets(snippetDirectories); SnippetDirectory[] releaseDirectories = snippetDirectories .Where(f => f.HasTag(KnownTags.Release) && !f.HasTag(KnownTags.Dev)) .ToArray(); MarkdownGenerator.WriteSolutionReadMe(releaseDirectories, settings); MarkdownGenerator.WriteProjectReadMe(releaseDirectories, Path.GetFullPath(settings.ProjectPath)); MarkdownGenerator.WriteDirectoryReadMe( snippetDirectories .Where(f => f.HasAnyTag(KnownTags.Release, KnownTags.Dev) && !f.HasAnyTag(KnownTags.AutoGenerationSource, KnownTags.AutoGenerationDestination)) .ToArray(), characterSequences, settings); SnippetPackageGenerator.GenerateVisualStudioPackageFiles( releaseDirectories: releaseDirectories, characterSequences: characterSequences, settings: settings); settings.ExtensionProjectName += ".Dev"; SnippetPackageGenerator.GenerateVisualStudioPackageFiles( releaseDirectories: snippetDirectories .Where(f => f.HasTags(KnownTags.Release, KnownTags.Dev)) .ToArray(), characterSequences: null, settings: settings); SnippetChecker.CheckSnippets(snippetDirectories); Console.WriteLine("*** END ***"); Console.ReadKey(); }
private static void GenerateSnippets2(SnippetDirectory[] snippetDirectories, LanguageDefinition languageDefinition) { if (snippetDirectories.Length > 0) { string source = snippetDirectories .Where(f => f.HasTag(KnownTags.AutoGenerationSource)) .Select(f => f.Path) .FirstOrDefault(); if (source != null) { string destination = snippetDirectories .Where(f => f.HasTag(KnownTags.AutoGenerationDestination)) .Select(f => f.Path) .FirstOrDefault(); if (destination != null) { var generator = new SnippetGenerator(languageDefinition); generator.GenerateSnippets(source, destination); } } } }