using System; using System.Collections.Generic; using System.Text; using MyDownloader.Spider.Web; using MyDownloader.Spider.Parsers.Html; namespace MyDownloader.Spider { public class Spider { private SpiderContext context; private ISpiderResourceFactory factory; public Spider(SpiderContext context, ISpiderResourceFactory factory) { this.context = context; this.factory = factory; } #region Events public event EventHandler Aborted; public event CompletedEventHandler Completed { add { context.Completed += value; } remove { context.Completed -= value; } } protected virtual void OnAborted() { if (Aborted != null) { Aborted(this, EventArgs.Empty); } } #endregion #region Properties public SpiderContext Context { get { return context; } } #endregion #region Methods public virtual IAsyncRetriver BeginLookup() { ISpiderResource resourceSpider = factory.CreateSpider(this.context, null, this.context.BaseLocation); context.AddURIToVisit(new Uri(this.context.BaseLocation), resourceSpider); return resourceSpider.BeginReceive(); } public virtual void Abort() { context.Abort(); OnAborted(); } #endregion } }
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.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)