Skip to content

Instantly share code, notes, and snippets.

@sjdirect
Created June 21, 2016 04:52
Show Gist options
  • Save sjdirect/99f6529e7b9e1a46bff6333060d30cc1 to your computer and use it in GitHub Desktop.
Save sjdirect/99f6529e7b9e1a46bff6333060d30cc1 to your computer and use it in GitHub Desktop.
using System;
using AbotX.Core;
using AbotX.Crawler;
using AbotX.Poco;
namespace AbotX.Parallel
{
public class ManualWebCrawlerFactory : IWebCrawlerFactory
{
private readonly CrawlConfigurationX _sharedConfig;
public ManualWebCrawlerFactory()
:this(null)
{
}
/// <summary>
/// Constructor to set a sharedConfig object that will be used by every instance created by this factory. Any changes to this
/// object will effect all current and future crawls.
/// </summary>
/// <param name="sharedConfig"></param>
public ManualWebCrawlerFactory(CrawlConfigurationX sharedConfig)
{
_sharedConfig = sharedConfig;
}
public ICrawlerX CreateInstance()
{
return CreateInstance(null);
}
public ICrawlerX CreateInstance(SiteToCrawl siteToCrawl)
{
var configToUse = _sharedConfig ?? new CrawlConfigurationX();
return new CrawlerX(configToUse, new ImplementationOverride(configToUse));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment