mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
Resharper Code cleanup.
This commit is contained in:
parent
57c296c62f
commit
6a9ee3f0b0
@ -11,15 +11,17 @@ public class Application
|
|||||||
private static readonly Logger Logger = LogManager.GetLogger("Host.App");
|
private static readonly Logger Logger = LogManager.GetLogger("Host.App");
|
||||||
|
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly WebClient _webClient;
|
|
||||||
private readonly IISProvider _iisProvider;
|
|
||||||
private readonly ConsoleProvider _consoleProvider;
|
private readonly ConsoleProvider _consoleProvider;
|
||||||
private readonly DebuggerProvider _debuggerProvider;
|
private readonly DebuggerProvider _debuggerProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnviromentProvider _enviromentProvider;
|
||||||
|
private readonly IISProvider _iisProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
|
private readonly WebClient _webClient;
|
||||||
|
|
||||||
public Application(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider, ConsoleProvider consoleProvider,
|
public Application(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider,
|
||||||
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider, ProcessProvider processProvider)
|
ConsoleProvider consoleProvider,
|
||||||
|
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider,
|
||||||
|
ProcessProvider processProvider)
|
||||||
{
|
{
|
||||||
_configProvider = configProvider;
|
_configProvider = configProvider;
|
||||||
_webClient = webClient;
|
_webClient = webClient;
|
||||||
@ -33,7 +35,6 @@ public Application(ConfigProvider configProvider, WebClient webClient, IISProvid
|
|||||||
_configProvider.CreateDefaultConfigFile();
|
_configProvider.CreateDefaultConfigFile();
|
||||||
Logger.Info("Starting NZBDrone. Start-up Path:'{0}'", _configProvider.ApplicationRoot);
|
Logger.Info("Starting NZBDrone. Start-up Path:'{0}'", _configProvider.ApplicationRoot);
|
||||||
Thread.CurrentThread.Name = "Host";
|
Thread.CurrentThread.Name = "Host";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
@ -71,8 +72,6 @@ public void Start()
|
|||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
using System;
|
using System.ServiceProcess;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.ServiceProcess;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NzbDrone
|
namespace NzbDrone
|
||||||
{
|
{
|
||||||
class NzbDroneService : ServiceBase
|
internal class NzbDroneService : ServiceBase
|
||||||
{
|
{
|
||||||
|
|
||||||
protected override void OnStart(string[] args)
|
protected override void OnStart(string[] args)
|
||||||
{
|
{
|
||||||
base.OnStart(args);
|
base.OnStart(args);
|
||||||
@ -18,6 +13,5 @@ protected override void OnStop()
|
|||||||
{
|
{
|
||||||
base.OnStop();
|
base.OnStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,6 @@ public static void Attach()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Get an instance of the currently running Visual Studio IDE.
|
// Get an instance of the currently running Visual Studio IDE.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region private
|
#region private
|
||||||
@ -88,9 +87,9 @@ private AttachResult Attach(AttachType attachType)
|
|||||||
|
|
||||||
private AttachResult PessimisticAttach(AttachType attachType)
|
private AttachResult PessimisticAttach(AttachType attachType)
|
||||||
{
|
{
|
||||||
AttachResult res = Attach(attachType);
|
var res = Attach(attachType);
|
||||||
|
|
||||||
DateTime timeout = DateTime.Now.AddSeconds(_waitTimeout);
|
var timeout = DateTime.Now.AddSeconds(_waitTimeout);
|
||||||
|
|
||||||
while (res == AttachResult.NotRunning && timeout > DateTime.Now)
|
while (res == AttachResult.NotRunning && timeout > DateTime.Now)
|
||||||
{
|
{
|
||||||
@ -102,8 +101,6 @@ private AttachResult PessimisticAttach(AttachType attachType)
|
|||||||
|
|
||||||
private bool IsBeingDebugged()
|
private bool IsBeingDebugged()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (_dte.Debugger.DebuggedProcesses != null)
|
if (_dte.Debugger.DebuggedProcesses != null)
|
||||||
{
|
{
|
||||||
foreach (Process process in _dte.Debugger.DebuggedProcesses)
|
foreach (Process process in _dte.Debugger.DebuggedProcesses)
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NzbDrone
|
namespace NzbDrone
|
||||||
{
|
{
|
||||||
@ -13,6 +9,5 @@ public class ProcessInfo
|
|||||||
public string StartPath { get; set; }
|
public string StartPath { get; set; }
|
||||||
|
|
||||||
public bool HasExited { get; set; }
|
public bool HasExited { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,7 +28,6 @@ private static void Main()
|
|||||||
Console.WriteLine("Starting Console.");
|
Console.WriteLine("Starting Console.");
|
||||||
Kernel.Get<MonitoringProvider>().Start();
|
Kernel.Get<MonitoringProvider>().Start();
|
||||||
Kernel.Get<Application>().Start();
|
Kernel.Get<Application>().Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ private string GetValue(string key, string parent = null)
|
|||||||
if (parent != null)
|
if (parent != null)
|
||||||
parentContainer = config.Descendants(parent).Single();
|
parentContainer = config.Descendants(parent).Single();
|
||||||
|
|
||||||
var value = parentContainer.Descendants(key).Single().Value;
|
string value = parentContainer.Descendants(key).Single().Value;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace NzbDrone.Providers
|
|||||||
{
|
{
|
||||||
public class DebuggerProvider
|
public class DebuggerProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetLogger("Host.DebuggerProvider");
|
private static readonly Logger Logger = LogManager.GetLogger("Host.DebuggerProvider");
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ public virtual void Attach()
|
|||||||
{
|
{
|
||||||
Logger.Info("Trying to attach to debugger");
|
Logger.Info("Trying to attach to debugger");
|
||||||
|
|
||||||
var count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -38,14 +37,10 @@ public virtual void Attach()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,10 +8,10 @@ namespace NzbDrone.Providers
|
|||||||
{
|
{
|
||||||
public class IISProvider
|
public class IISProvider
|
||||||
{
|
{
|
||||||
private readonly ConfigProvider _configProvider;
|
|
||||||
private readonly ProcessProvider _processProvider;
|
|
||||||
private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress");
|
private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress");
|
||||||
private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider");
|
private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider");
|
||||||
|
private readonly ConfigProvider _configProvider;
|
||||||
|
private readonly ProcessProvider _processProvider;
|
||||||
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
@ -19,12 +19,10 @@ public IISProvider(ConfigProvider configProvider, ProcessProvider processProvide
|
|||||||
{
|
{
|
||||||
_configProvider = configProvider;
|
_configProvider = configProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IISProvider()
|
public IISProvider()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AppUrl
|
public string AppUrl
|
||||||
@ -141,7 +139,5 @@ private string NormalizePath(string path)
|
|||||||
|
|
||||||
return info.FullName.Trim('/', '\\', ' ').ToLower();
|
return info.FullName.Trim('/', '\\', ' ').ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
|
||||||
using System.Runtime.Remoting;
|
using System.Runtime.Remoting;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using NLog;
|
using NLog;
|
||||||
@ -14,15 +13,22 @@ public class MonitoringProvider
|
|||||||
|
|
||||||
private readonly IISProvider _iisProvider;
|
private readonly IISProvider _iisProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
|
private readonly WebClientProvider _webClientProvider;
|
||||||
|
|
||||||
private int _pingFailCounter;
|
private int _pingFailCounter;
|
||||||
private Timer _pingTimer;
|
private Timer _pingTimer;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public MonitoringProvider(ProcessProvider processProvider, IISProvider iisProvider)
|
public MonitoringProvider(ProcessProvider processProvider, IISProvider iisProvider,
|
||||||
|
WebClientProvider webClientProvider)
|
||||||
{
|
{
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
_iisProvider = iisProvider;
|
_iisProvider = iisProvider;
|
||||||
|
_webClientProvider = webClientProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MonitoringProvider()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
@ -41,10 +47,6 @@ public void Start()
|
|||||||
_pingTimer.Start();
|
_pingTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MonitoringProvider()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public virtual void EnsurePriority(object sender, ElapsedEventArgs e)
|
public virtual void EnsurePriority(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -68,16 +70,18 @@ public virtual void PingServer(object sender, ElapsedEventArgs e)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string response = new WebClient().DownloadString(_iisProvider.AppUrl + "/health");
|
string response = _webClientProvider.DownloadString(_iisProvider.AppUrl + "/health");
|
||||||
|
|
||||||
if (!response.Contains("OK"))
|
if (!response.Contains("OK"))
|
||||||
{
|
{
|
||||||
throw new ServerException("Health services responded with an invalid response.");
|
throw new ServerException("Health services responded with an invalid response.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pingFailCounter > 0)
|
if (_pingFailCounter > 0)
|
||||||
{
|
{
|
||||||
Logger.Info("Application pool has been successfully recovered.");
|
Logger.Info("Application pool has been successfully recovered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_pingFailCounter = 0;
|
_pingFailCounter = 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -18,7 +18,7 @@ public class ServiceProvider
|
|||||||
public bool ServiceExist(string name)
|
public bool ServiceExist(string name)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
System.ServiceProcess.ServiceController.GetServices().Any(
|
ServiceController.GetServices().Any(
|
||||||
s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
|
s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
using System;
|
using System.Net;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NzbDrone.Providers
|
namespace NzbDrone.Providers
|
||||||
{
|
{
|
||||||
public class WebClientProvider
|
public class WebClientProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
public virtual string DownloadString(string url)
|
public virtual string DownloadString(string url)
|
||||||
{
|
{
|
||||||
return new WebClient().DownloadString(url);
|
return new WebClient().DownloadString(url);
|
||||||
|
Loading…
Reference in New Issue
Block a user