added a shutdown api method, font size fix and other decouplings

This commit is contained in:
LukePulverenti
2013-02-26 11:10:55 -05:00
parent efdb2f3990
commit 6efd22a3d2
30 changed files with 420 additions and 235 deletions

View File

@@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Serialization;
@@ -29,6 +30,11 @@ namespace MediaBrowser.Api
{
}
[Route("/System/Shutdown", "POST")]
public class ShutdownApplication
{
}
/// <summary>
/// Class GetConfiguration
/// </summary>
@@ -61,19 +67,30 @@ namespace MediaBrowser.Api
/// </summary>
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _app host
/// </summary>
private readonly IApplicationHost _appHost;
/// <summary>
/// Initializes a new instance of the <see cref="SystemService" /> class.
/// </summary>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="appHost">The app host.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public SystemService(IJsonSerializer jsonSerializer)
public SystemService(IJsonSerializer jsonSerializer, IApplicationHost appHost)
: base()
{
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
if (appHost == null)
{
throw new ArgumentNullException("appHost");
}
_appHost = appHost;
_jsonSerializer = jsonSerializer;
}
@@ -118,6 +135,19 @@ namespace MediaBrowser.Api
});
}
/// <summary>
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
public void Post(ShutdownApplication request)
{
Task.Run(async () =>
{
await Task.Delay(100);
_appHost.Shutdown();
});
}
/// <summary>
/// Posts the specified configuraiton.
/// </summary>

View File

@@ -1,6 +1,5 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
@@ -27,18 +26,20 @@ namespace MediaBrowser.Api.WebSocket
/// <summary>
/// The _kernel
/// </summary>
private readonly IApplicationHost _appHost;
private readonly IKernel _kernel;
/// <summary>
/// Initializes a new instance of the <see cref="LogFileWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="kernel">The kernel.</param>
public LogFileWebSocketListener(ILogger logger, Kernel kernel)
public LogFileWebSocketListener(ILogger logger, IApplicationHost host, IKernel kernel)
: base(logger)
{
_appHost = host;
_kernel = kernel;
_kernel.LoggerLoaded += kernel_LoggerLoaded;
kernel.LoggerLoaded += kernel_LoggerLoaded;
}
/// <summary>
@@ -48,9 +49,9 @@ namespace MediaBrowser.Api.WebSocket
/// <returns>IEnumerable{System.String}.</returns>
protected override async Task<IEnumerable<string>> GetDataToSend(LogFileWebSocketState state)
{
if (!string.Equals(_kernel.LogFilePath, state.LastLogFilePath))
if (!string.Equals(_appHost.LogFilePath, state.LastLogFilePath))
{
state.LastLogFilePath = _kernel.LogFilePath;
state.LastLogFilePath = _appHost.LogFilePath;
state.StartLine = 0;
}