Skip to content

Instantly share code, notes, and snippets.

@sjdirect
Created June 8, 2016 02:14
Show Gist options
  • Save sjdirect/88c571e0784b20046307a56ee6bc2bcf to your computer and use it in GitHub Desktop.
Save sjdirect/88c571e0784b20046307a56ee6bc2bcf to your computer and use it in GitHub Desktop.
Used by the ParallelCrawlEngine to create individual instances of CrawlerX.
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