private void RemoveItem(string relativePath, OutputFileInfo item) { if (_index.TryGetValue(NormalizePath(relativePath), out List <OutputFileInfo> list)) { list.Remove(item); } }
private void RemoveItem(string relativePath, OutputFileInfo item) { List <OutputFileInfo> list; if (_index.TryGetValue(relativePath, out list)) { list.Remove(item); } }
private void AddItem(string relativePath, OutputFileInfo item) { var rp = NormalizePath(relativePath); if (_index.TryGetValue(rp, out List <OutputFileInfo> list)) { list.Add(item); } else { _index[rp] = new List <OutputFileInfo> { item }; } }
private void AddItem(string relativePath, OutputFileInfo item) { List <OutputFileInfo> list; if (_index.TryGetValue(relativePath, out list)) { list.Add(item); } else { _index[relativePath] = new List <OutputFileInfo> { item }; } }
public void TestIndexDotJsonWithNonEnglishCharacters() { var rawHtml = @" <!DOCTYPE html> <html> <head> <meta charset=""utf-8""> <title>This is title in head metadata</title> </head> <body> <h1> This is Title </h1> <p class='data-searchable'> Hello World, Microsoft </p> <article> <h1> This is article title </h1> docfx can do anything... and it supports non-english characters like these: ãâáà êé í õôó Типы шрифтов 人物 文字 </article> </body> </html> "; // prepares temp folder and file for testing purposes // ExtractSearchIndex should probably be refactored so we can test it without depending on the filesystem var tempTestFolder = "temp_test_folder"; if (Directory.Exists(tempTestFolder)) Directory.Delete(tempTestFolder, true); Directory.CreateDirectory(tempTestFolder); File.WriteAllText(Path.Combine(tempTestFolder, "index.html"), rawHtml, new UTF8Encoding(false)); // prepares fake manifest object var outputFileInfo = new OutputFileInfo(); outputFileInfo.RelativePath = "index.html"; var manifestItem = new ManifestItem() { OutputFiles = new Dictionary<string, OutputFileInfo>() }; manifestItem.OutputFiles.Add(".html", outputFileInfo); var manifest = new Manifest() { Files = new List<ManifestItem>() }; manifest.Files.Add(manifestItem); // process the fake manifest, using tempTestFolder as the output folder _extractor.Process(manifest, tempTestFolder); var expectedIndexJSON = @"{ ""index.html"": { ""href"": ""index.html"", ""title"": ""This is title in head metadata"", ""keywords"": ""Hello World, Microsoft This is article title docfx can do anything... and it supports non-english characters like these: ãâáà êé í õôó Типы шрифтов 人物 文字"" } }"; var actualIndexJSON = File.ReadAllText(Path.Combine(tempTestFolder, "index.json"), Encoding.UTF8); Assert.Equal(expectedIndexJSON, actualIndexJSON); }