|
using IpWatchDog.Install;
using IpWatchDog.Log;
using IpWatchDog.Runners;
namespace IpWatchDog
{
class Configurator
{
private ILog _log;
private bool _isConsole;
public Configurator(bool isConsole)
{
_isConsole = isConsole;
_log =
isConsole ?
(ILog)new ConsoleLog() :
new SystemLog(StringConstants.ServiceName);
}
public IRunner CreateRunner()
{
var service = CreateWatchDogService();
return _isConsole ?
(IRunner)new ConsoleRunner(service) :
new ServiceRunner(service, StringConstants.ServiceName);
}
public InstallUtil CreateInstaller()
{
return new InstallUtil(_log);
}
public IService CreateServiceController()
{
return new ServiceController(_log);
}
private IService CreateWatchDogService()
{
var config = new AppConfig();
var notifier = CreateNotifier(config);
return new IpWatchDogService(
_log,
config,
new IpPersistor(_log),
new WebIpRetriever(_log),
notifier);
}
private IIpNotifier CreateNotifier(AppConfig config)
{
if (string.IsNullOrEmpty(config.Command))
{
return new MailIpNotifier(_log, config);
}
else
{
return new CommandIpNotifier(_log, config);
}
}
}
}
|
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.
Ivan is a hands-on software architect/technical lead working for Thomson Reuters in the New York City area. At present I am mostly building complex multi-threaded WPF application for the financial sector, but I am also interested in cloud computing, web development, mobile development, etc.
Please visit my web site:
www.ikriv.com.