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