mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
using System.Linq;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
if (_processProvider.GetProcessByName(ProcessProvider.NzbDroneConsoleProcessName).Any())
|
||
|
{
|
||
|
return AppType.Console;
|
||
|
}
|
||
|
|
||
|
return AppType.Normal;
|
||
|
}
|
||
|
}
|
||
|
}
|