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:
parent
57c296c62f
commit
6a9ee3f0b0
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace NzbDrone
|
||||
public static void Attach()
|
||||
{
|
||||
DTE2 dte2;
|
||||
dte2 = (DTE2)Marshal.
|
||||
dte2 = (DTE2) Marshal.
|
||||
GetActiveObject("VisualStudio.DTE.10.0");
|
||||
|
||||
var pa = new ProcessAttacher(dte2, "iisexpress", 10);
|
||||
@ -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)
|
||||
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ namespace NzbDrone
|
||||
Console.WriteLine("Starting Console.");
|
||||
Kernel.Get<MonitoringProvider>().Start();
|
||||
Kernel.Get<Application>().Start();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -36,4 +36,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("0.5.0.*")]
|
||||
[assembly: AssemblyVersion("0.5.0.*")]
|
@ -88,10 +88,10 @@ namespace NzbDrone.Providers
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", Port))
|
||||
));
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", Port))
|
||||
));
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
@ -112,10 +112,10 @@ namespace NzbDrone.Providers
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
|
||||
xDoc.Add(new XElement("Config",
|
||||
new XElement("Port", 8989),
|
||||
new XElement("LaunchBrowser", true)
|
||||
)
|
||||
);
|
||||
new XElement("Port", 8989),
|
||||
new XElement("LaunchBrowser", true)
|
||||
)
|
||||
);
|
||||
|
||||
xDoc.Save(ConfigFile);
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ namespace NzbDrone.Providers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -14,4 +14,4 @@ namespace NzbDrone.Providers
|
||||
get { return Environment.UserInteractive; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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()
|
||||
@ -36,15 +42,11 @@ namespace NzbDrone.Providers
|
||||
prioCheckTimer.Elapsed += EnsurePriority;
|
||||
prioCheckTimer.Enabled = true;
|
||||
|
||||
_pingTimer = new Timer(60000) { AutoReset = true };
|
||||
_pingTimer = new Timer(60000) {AutoReset = true};
|
||||
_pingTimer.Elapsed += (PingServer);
|
||||
_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)
|
||||
|
@ -76,11 +76,11 @@ namespace NzbDrone.Providers
|
||||
if (process == null) return null;
|
||||
|
||||
return new ProcessInfo
|
||||
{
|
||||
Id = process.Id,
|
||||
Priority = process.PriorityClass,
|
||||
StartPath = process.MainModule.FileName
|
||||
};
|
||||
{
|
||||
Id = process.Id,
|
||||
Priority = process.PriorityClass,
|
||||
StartPath = process.MainModule.FileName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ namespace NzbDrone.Providers
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Host.ServiceManager");
|
||||
|
||||
|
||||
|
||||
public bool ServiceExist(string name)
|
||||
{
|
||||
return
|
||||
System.ServiceProcess.ServiceController.GetServices().Any(
|
||||
ServiceController.GetServices().Any(
|
||||
s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace NzbDrone.Providers
|
||||
var serviceInstaller = new ServiceInstaller();
|
||||
|
||||
|
||||
String[] cmdline = { @"/assemblypath=" + Assembly.GetExecutingAssembly().Location };
|
||||
String[] cmdline = {@"/assemblypath=" + Assembly.GetExecutingAssembly().Location};
|
||||
|
||||
var context = new InstallContext("service_install.log", cmdline);
|
||||
serviceInstaller.Context = context;
|
||||
|
@ -1,17 +1,12 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user