2013-05-21 04:03:05 +00:00
|
|
|
using NzbDrone.Common;
|
2013-09-20 23:56:17 +00:00
|
|
|
using NzbDrone.Common.Processes;
|
2013-05-21 04:03:05 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Update.UpdateEngine
|
|
|
|
{
|
|
|
|
public interface IDetectApplicationType
|
|
|
|
{
|
|
|
|
AppType GetAppType();
|
|
|
|
}
|
|
|
|
|
|
|
|
public class DetectApplicationType : IDetectApplicationType
|
|
|
|
{
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
private readonly IProcessProvider _processProvider;
|
|
|
|
|
|
|
|
public DetectApplicationType(IServiceProvider serviceProvider, IProcessProvider processProvider)
|
|
|
|
{
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
_processProvider = processProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AppType GetAppType()
|
|
|
|
{
|
|
|
|
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)
|
|
|
|
&& _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
|
|
|
{
|
|
|
|
return AppType.Service;
|
|
|
|
}
|
|
|
|
|
2013-08-14 05:20:24 +00:00
|
|
|
if (_processProvider.Exists(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME))
|
2013-05-21 04:03:05 +00:00
|
|
|
{
|
|
|
|
return AppType.Console;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AppType.Normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|