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); } } }
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); }
private Stream Load(HelpRegistration registration, string path) { return _resolvers.GetOrAdd(registration, p => new Resolver(p)).Load(path); }
public HResult Register(string root, string source) { try { if (root == null) throw new ArgumentNullException("root"); if (source == null) throw new ArgumentNullException("source"); var helpRegistration = new HelpRegistration(root, source); _registrations.Add(helpRegistration); if (_server != null) _server.Manager.Registrations.Add(helpRegistration); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
private Stream Load(HelpRegistration registration, string path) { return(_resolvers.GetOrAdd(registration, p => new Resolver(p)).Load(path)); }