private static IEnumerable <Snippet> EnumerateSnippets(string directoryPath) { foreach (string path in Directory.EnumerateDirectories(directoryPath, "*", SearchOption.TopDirectoryOnly)) { string name = Path.GetFileName(path); if (name == KnownNames.Dev) { continue; } if (name == KnownNames.AutoGeneration) { continue; } foreach (Snippet snippet in SnippetSerializer.Deserialize(path, SearchOption.AllDirectories)) { yield return(snippet); } } foreach (string filePath in Directory.EnumerateFiles(directoryPath, SnippetFileSearcher.Pattern, SearchOption.TopDirectoryOnly)) { foreach (Snippet snippet in SnippetSerializer.DeserializeFile(filePath).Snippets) { yield return(snippet); } } }
public void GenerateSnippets(string sourceDirectoryPath, string destinationDirectoryPath) { Snippet[] snippets = SnippetSerializer.Deserialize(sourceDirectoryPath, SearchOption.AllDirectories) .SelectMany(snippet => GenerateSnippets(snippet)) .ToArray(); IOUtility.SaveSnippets(snippets, destinationDirectoryPath); }
public static IEnumerable <Snippet> GenerateSnippets(string sourceDirectoryPath) { foreach (Snippet snippet in GenerateSnippets(SnippetSerializer.Deserialize(sourceDirectoryPath, SearchOption.AllDirectories))) { snippet.AddTag(KnownTags.AutoGenerated); snippet.SortCollections(); yield return(snippet); } }
public void Snippet_Deserialize() { const string filePath = @"..\..\..\Snippet.snippet"; Snippet snippet = null; using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) snippet = SnippetSerializer.Deserialize(stream).FirstOrDefault(); var settings = new SaveSettings() { IndentChars = " ", OmitCodeSnippetsElement = true, OmitXmlDeclaration = true, Comment = " comment " }; string oldValue = File.ReadAllText(filePath, Encoding.UTF8); string newValue = SnippetSerializer.CreateXml(snippet, settings); Assert.Equal(oldValue, newValue); }
public IEnumerable <Snippet> EnumerateSnippets(SearchOption searchOption = SearchOption.AllDirectories) { return(SnippetSerializer.Deserialize(Path, searchOption)); }
public IEnumerable <Snippet> GenerateSnippets(string sourceDirectoryPath, SearchOption searchOption = SearchOption.AllDirectories) { return(SnippetSerializer.Deserialize(sourceDirectoryPath, searchOption) .SelectMany(snippet => GenerateSnippets(snippet))); }