2013-05-21 07:03:05 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
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-07-30 23:19:09 +03:00
|
|
|
if (_processProvider.Exists(ProcessProvider.NzbDroneConsoleProcessName))
|
2013-05-21 07:03:05 +03:00
|
|
|
{
|
|
|
|
return AppType.Console;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AppType.Normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|