예제 #1
0
        override public ISnippetReader GetSnippet(string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length)
        {
            if (text_cache == null)
            {
                return(null);
            }

            Uri uri;

            if (mount_dir == null || hit ["beagle:RemovableUri"] == null)
            {
                uri = hit.Uri;
            }
            else
            {
                uri = UriFu.EscapedStringToUri(hit ["beagle:RemovableUri"]);
            }

            // Look up the hit in our local text cache.
            // Need to handle self-cached removable:/// uris
            bool       self_cache = true;
            TextReader reader     = text_cache.GetReader(uri, ref self_cache);

            if (self_cache)
            {
                reader = new StreamReader(hit.Uri.LocalPath);
            }
            else if (reader == null)
            {
                return(null);
            }

            return(SnippetFu.GetSnippet(query_terms, reader, full_text, ctx_length, snp_length));
        }
예제 #2
0
        /////////////////////////////////////////

        protected SnippetReader GetSnippetFromTextCache(string [] query_terms, Uri uri, bool full_text, int ctx_length, int snp_length)
        {
            // Look up the hit in our text cache.  If it is there,
            // use the cached version to generate a snippet.

            TextReader reader;

            reader = TextCache.UserCache.GetReader(uri);
            if (reader == null)
            {
                return(null);
            }

            return(SnippetFu.GetSnippet(query_terms, reader, full_text, ctx_length, snp_length));
        }