1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-25 20:22:37 +01:00

Resharper Code cleanup.

This commit is contained in:
kay.one 2011-10-06 23:57:43 -07:00
parent 57c296c62f
commit 6a9ee3f0b0
15 changed files with 54 additions and 80 deletions

View File

@ -11,15 +11,17 @@ namespace NzbDrone
private static readonly Logger Logger = LogManager.GetLogger("Host.App");
private readonly ConfigProvider _configProvider;
private readonly WebClient _webClient;
private readonly IISProvider _iisProvider;
private readonly ConsoleProvider _consoleProvider;
private readonly DebuggerProvider _debuggerProvider;
private readonly EnviromentProvider _enviromentProvider;
private readonly IISProvider _iisProvider;
private readonly ProcessProvider _processProvider;
private readonly WebClient _webClient;
public Application(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider, ConsoleProvider consoleProvider,
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider, ProcessProvider processProvider)
public Application(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider,
ConsoleProvider consoleProvider,
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider,
ProcessProvider processProvider)
{
_configProvider = configProvider;
_webClient = webClient;
@ -33,7 +35,6 @@ namespace NzbDrone
_configProvider.CreateDefaultConfigFile();
Logger.Info("Starting NZBDrone. Start-up Path:'{0}'", _configProvider.ApplicationRoot);
Thread.CurrentThread.Name = "Host";
}
public void Start()
@ -71,8 +72,6 @@ namespace NzbDrone
public void Stop()
{
}
}
}

View File

@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ServiceProcess;
namespace NzbDrone
{
class NzbDroneService : ServiceBase
internal class NzbDroneService : ServiceBase
{
protected override void OnStart(string[] args)
{
base.OnStart(args);
@ -18,6 +13,5 @@ namespace NzbDrone
{
base.OnStop();
}
}
}

View File

@ -27,7 +27,6 @@ namespace NzbDrone
return;
// Get an instance of the currently running Visual Studio IDE.
}
#region private
@ -88,9 +87,9 @@ namespace NzbDrone
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)
{
@ -102,8 +101,6 @@ namespace NzbDrone
private bool IsBeingDebugged()
{
if (_dte.Debugger.DebuggedProcesses != null)
{
foreach (Process process in _dte.Debugger.DebuggedProcesses)

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace NzbDrone
{
@ -13,6 +9,5 @@ namespace NzbDrone
public string StartPath { get; set; }
public bool HasExited { get; set; }
}
}

View File

@ -28,7 +28,6 @@ namespace NzbDrone
Console.WriteLine("Starting Console.");
Kernel.Get<MonitoringProvider>().Start();
Kernel.Get<Application>().Start();
}
catch (Exception e)
{

View File

@ -130,7 +130,7 @@ namespace NzbDrone.Providers
if (parent != null)
parentContainer = config.Descendants(parent).Single();
var value = parentContainer.Descendants(key).Single().Value;
string value = parentContainer.Descendants(key).Single().Value;
return value;
}

View File

@ -7,7 +7,6 @@ namespace NzbDrone.Providers
{
public class DebuggerProvider
{
private static readonly Logger Logger = LogManager.GetLogger("Host.DebuggerProvider");
@ -18,7 +17,7 @@ namespace NzbDrone.Providers
{
Logger.Info("Trying to attach to debugger");
var count = 0;
int count = 0;
while (true)
{
@ -38,14 +37,10 @@ namespace NzbDrone.Providers
}
Thread.Sleep(100);
}
}
}
#endif
}
}
}

View File

@ -8,10 +8,10 @@ namespace NzbDrone.Providers
{
public class IISProvider
{
private readonly ConfigProvider _configProvider;
private readonly ProcessProvider _processProvider;
private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress");
private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider");
private readonly ConfigProvider _configProvider;
private readonly ProcessProvider _processProvider;
[Inject]
@ -19,12 +19,10 @@ namespace NzbDrone.Providers
{
_configProvider = configProvider;
_processProvider = processProvider;
}
public IISProvider()
{
}
public string AppUrl
@ -141,7 +139,5 @@ namespace NzbDrone.Providers
return info.FullName.Trim('/', '\\', ' ').ToLower();
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Runtime.Remoting;
using System.Timers;
using NLog;
@ -14,15 +13,22 @@ namespace NzbDrone.Providers
private readonly IISProvider _iisProvider;
private readonly ProcessProvider _processProvider;
private readonly WebClientProvider _webClientProvider;
private int _pingFailCounter;
private Timer _pingTimer;
[Inject]
public MonitoringProvider(ProcessProvider processProvider, IISProvider iisProvider)
public MonitoringProvider(ProcessProvider processProvider, IISProvider iisProvider,
WebClientProvider webClientProvider)
{
_processProvider = processProvider;
_iisProvider = iisProvider;
_webClientProvider = webClientProvider;
}
public MonitoringProvider()
{
}
public void Start()
@ -41,10 +47,6 @@ namespace NzbDrone.Providers
_pingTimer.Start();
}
public MonitoringProvider()
{
}
public virtual void EnsurePriority(object sender, ElapsedEventArgs e)
{
@ -68,16 +70,18 @@ namespace NzbDrone.Providers
try
{
string response = new WebClient().DownloadString(_iisProvider.AppUrl + "/health");
string response = _webClientProvider.DownloadString(_iisProvider.AppUrl + "/health");
if (!response.Contains("OK"))
{
throw new ServerException("Health services responded with an invalid response.");
}
if (_pingFailCounter > 0)
{
Logger.Info("Application pool has been successfully recovered.");
}
_pingFailCounter = 0;
}
catch (Exception ex)

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Providers
public bool ServiceExist(string name)
{
return
System.ServiceProcess.ServiceController.GetServices().Any(
ServiceController.GetServices().Any(
s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
}

View File

@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Net;
namespace NzbDrone.Providers
{
public class WebClientProvider
{
public virtual string DownloadString(string url)
{
return new WebClient().DownloadString(url);