Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
 public Resolver(HelpRegistration registration)
 {
     _source = HelpSource.FromSource(registration.Source);
 }
Пример #4
0
 private Stream Load(HelpRegistration registration, string path)
 {
     return _resolvers.GetOrAdd(registration, p => new Resolver(p)).Load(path);
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
 private Stream Load(HelpRegistration registration, string path)
 {
     return(_resolvers.GetOrAdd(registration, p => new Resolver(p)).Load(path));
 }
Пример #7
0
 public Resolver(HelpRegistration registration)
 {
     _source = HelpSource.FromSource(registration.Source);
 }