Click here to Skip to main content
15,896,154 members
Articles / Web Development / ASP.NET

Searcharoo 2007 (Medium Trust and Office 2007 indexing)

Rate me:
Please Sign up or sign in to vote.
4.95/5 (11 votes)
28 Apr 2007CPOL10 min read 205.2K   849   42  
Remove Binary Serialization to solve Medium Trust problem; index OpenXML document formats in ASP.NET/C# free search engine
using System;
using System.Collections.Generic;
using System.Text;

namespace Searcharoo.Common
{
    /// <summary>
    /// ASCII Text Document (text/plain)
    /// </summary>
    public class TextDocument : Document
    {
        private string _All;
        private string _WordsOnly;

        public override string WordsOnly
        {
            get { return _WordsOnly; }
        }
        public override string[] WordsArray
        {
            get { return this.WordsStringToArray(WordsOnly); }
        }
        /// <summary>
        /// Set 'all' and 'words only' to the same value (no parsing)
        /// </summary>
        public override string All {
            get { return _All; }
            set { 
                _All = value;
                _WordsOnly = value;
            }
        }

        

        #region Constructor requires Uri
        public TextDocument(Uri location):base(location)
        {}
        #endregion

        public override void Parse()
        {
            // no parsing, by default the content is used "as is"
        }
        public override bool GetResponse(System.Net.HttpWebResponse webresponse)
        {
            //http://www.c-sharpcorner.com/Code/2003/Dec/ReadingWebPageSources.asp
            System.IO.StreamReader stream = new System.IO.StreamReader
                (webresponse.GetResponseStream(), System.Text.Encoding.ASCII);

            this.Uri = webresponse.ResponseUri; // we *may* have been redirected... and we want the *final* URL
            this.Length = webresponse.ContentLength;
            this.All = stream.ReadToEnd();
            this.Title = System.IO.Path.GetFileName(this.Uri.AbsoluteUri);
            this.Description = base.GetDescriptionFromWordsOnly(WordsOnly);
            stream.Close();
            return true; 
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
-- ooo ---
www.conceptdevelopment.net
conceptdev.blogspot.com
www.searcharoo.net
www.recipenow.net
www.racereplay.net
www.silverlightearth.com

Comments and Discussions