Created
June 8, 2016 02:14
-
-
Save sjdirect/88c571e0784b20046307a56ee6bc2bcf to your computer and use it in GitHub Desktop.
Used by the ParallelCrawlEngine to create individual instances of CrawlerX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Abot.Core; | |
using Abot.Crawler; | |
using Abot.Poco; | |
using AbotX.Core; | |
using AbotX.Crawler; | |
using AbotX.Poco; | |
namespace AbotX.Parallel | |
{ | |
public interface IWebCrawlerFactory | |
{ | |
ICrawlerX CreateInstance(); | |
} | |
public class WebCrawlerFactory : IWebCrawlerFactory | |
{ | |
readonly CrawlConfigurationX _config; | |
public WebCrawlerFactory() | |
{ | |
_config = GetConfigFromFile(); | |
} | |
public ICrawlerX CreateInstance() | |
{ | |
return new CrawlerX(_config, new ImplementationOverride(_config)); | |
} | |
private CrawlConfigurationX GetConfigFromFile() | |
{ | |
var configFromFile = AbotXConfigurationSectionHandler.LoadFromXml().Convert(); | |
if (configFromFile == null) | |
throw new ApplicationException("Config section \"abotx\" was NOT found"); | |
return configFromFile; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment