private void RebuildDatabase(IndexWriter writer, HelpRegistration registration) { using (var source = HelpSource.FromSource(registration.Source)) { foreach (var entry in source) { if (!entry.Name.EndsWith(".html", StringComparison.OrdinalIgnoreCase)) { continue; } Parsed parsed; using (var stream = entry.GetInputStream()) { parsed = ParseDocument(stream); } string path = String.Format("/{0}/{1}", registration.Root, entry.Name); var title = parsed.Title; if (title == null) { int index = entry.Name.LastIndexOf('/'); if (index == -1) { title = entry.Name; } else { title = entry.Name.Substring(index + 1); } } var document = new Document(); document.Add(new Field(PathField, path, Field.Store.YES, Field.Index.NO)); document.Add(new Field(TitleField, title, Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field(ContentField, parsed.GetContent(), Field.Store.YES, Field.Index.ANALYZED)); writer.AddDocument(document); } } }
public Resolver(HelpRegistration registration) { _source = HelpSource.FromSource(registration.Source); }