2011-10-09 04:16:11 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2011-10-09 19:45:08 +02:00
|
|
|
|
using NzbDrone.Model;
|
2011-10-09 04:16:11 +02:00
|
|
|
|
using NzbDrone.Providers;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone
|
|
|
|
|
{
|
|
|
|
|
class Router
|
|
|
|
|
{
|
2011-10-11 09:11:05 +02:00
|
|
|
|
private readonly ApplicationServer _applicationServer;
|
2011-10-09 04:16:11 +02:00
|
|
|
|
private readonly ServiceProvider _serviceProvider;
|
|
|
|
|
private readonly ConsoleProvider _consoleProvider;
|
|
|
|
|
|
2011-10-11 09:11:05 +02:00
|
|
|
|
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider)
|
2011-10-09 04:16:11 +02:00
|
|
|
|
{
|
2011-10-11 09:11:05 +02:00
|
|
|
|
_applicationServer = applicationServer;
|
2011-10-09 04:16:11 +02:00
|
|
|
|
_serviceProvider = serviceProvider;
|
2011-10-11 09:11:05 +02:00
|
|
|
|
_consoleProvider = consoleProvider;
|
2011-10-09 04:16:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Route()
|
|
|
|
|
{
|
2011-10-11 09:11:05 +02:00
|
|
|
|
switch (CentralDispatch.ApplicationMode)
|
2011-10-09 04:16:11 +02:00
|
|
|
|
{
|
|
|
|
|
case ApplicationMode.Console:
|
|
|
|
|
{
|
2011-10-11 09:11:05 +02:00
|
|
|
|
_applicationServer.Start();
|
2011-10-09 04:16:11 +02:00
|
|
|
|
_consoleProvider.WaitForClose();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ApplicationMode.InstallService:
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider.Install();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ApplicationMode.UninstallService:
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider.UnInstall();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
_consoleProvider.PrintHelp();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|