aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
authorMark Monteiro <marknr.monteiro@protonmail.com>2020-03-11 23:04:47 +0100
committerMark Monteiro <marknr.monteiro@protonmail.com>2020-03-11 23:04:47 +0100
commit99bf6edba27c48db6094d1364a7175a0af9158b5 (patch)
tree87ea497716c6e92ae9b7e3cfc540256350b05430 /Emby.Server.Implementations/ApplicationHost.cs
parentd437950ac30ee294ab275362abe711ae3c14ac32 (diff)
parent008a76cf4d7f04eee2f0e1b8d135ea835d7ec7e2 (diff)
Merge remote-tracking branch 'upstream/master' into support-running-without-web-content
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs40
1 files changed, 15 insertions, 25 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 8ea188724..3d79cae1e 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -119,7 +119,6 @@ namespace Emby.Server.Implementations
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{
private SqliteUserRepository _userRepository;
-
private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
/// <summary>
@@ -167,10 +166,9 @@ namespace Emby.Server.Implementations
public bool IsShuttingDown { get; private set; }
/// <summary>
- /// Gets or sets the logger.
+ /// Gets the logger.
/// </summary>
- /// <value>The logger.</value>
- protected ILogger Logger { get; set; }
+ protected ILogger Logger { get; }
private IPlugin[] _plugins;
@@ -181,10 +179,9 @@ namespace Emby.Server.Implementations
public IReadOnlyList<IPlugin> Plugins => _plugins;
/// <summary>
- /// Gets or sets the logger factory.
+ /// Gets the logger factory.
/// </summary>
- /// <value>The logger factory.</value>
- public ILoggerFactory LoggerFactory { get; protected set; }
+ protected ILoggerFactory LoggerFactory { get; }
/// <summary>
/// Gets or sets the application paths.
@@ -328,8 +325,6 @@ namespace Emby.Server.Implementations
private IMediaSourceManager MediaSourceManager { get; set; }
- private readonly IConfiguration _configuration;
-
/// <summary>
/// Gets the installation manager.
/// </summary>
@@ -367,11 +362,8 @@ namespace Emby.Server.Implementations
IStartupOptions options,
IFileSystem fileSystem,
IImageEncoder imageEncoder,
- INetworkManager networkManager,
- IConfiguration configuration)
+ INetworkManager networkManager)
{
- _configuration = configuration;
-
XmlSerializer = new MyXmlSerializer();
NetworkManager = networkManager;
@@ -587,7 +579,8 @@ namespace Emby.Server.Implementations
}
}
- public async Task InitAsync(IServiceCollection serviceCollection)
+ /// <inheritdoc/>
+ public async Task InitAsync(IServiceCollection serviceCollection, IConfiguration startupConfig)
{
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
@@ -620,7 +613,7 @@ namespace Emby.Server.Implementations
DiscoverTypes();
- await RegisterResources(serviceCollection).ConfigureAwait(false);
+ await RegisterResources(serviceCollection, startupConfig).ConfigureAwait(false);
ContentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath;
if (string.IsNullOrEmpty(ContentRoot))
@@ -652,14 +645,14 @@ namespace Emby.Server.Implementations
var response = context.Response;
var localPath = context.Request.Path.ToString();
- var req = new WebSocketSharpRequest(request, response, request.Path, Logger);
+ var req = new WebSocketSharpRequest(request, response, request.Path, LoggerFactory.CreateLogger<WebSocketSharpRequest>());
await HttpServer.RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted).ConfigureAwait(false);
}
/// <summary>
/// Registers resources that classes will depend on
/// </summary>
- protected async Task RegisterResources(IServiceCollection serviceCollection)
+ protected async Task RegisterResources(IServiceCollection serviceCollection, IConfiguration startupConfig)
{
serviceCollection.AddMemoryCache();
@@ -668,13 +661,10 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
- serviceCollection.AddSingleton<IConfiguration>(_configuration);
-
serviceCollection.AddSingleton(JsonSerializer);
- serviceCollection.AddSingleton(LoggerFactory);
- serviceCollection.AddLogging();
- serviceCollection.AddSingleton(Logger);
+ // TODO: Support for injecting ILogger should be deprecated in favour of ILogger<T> and this removed
+ serviceCollection.AddSingleton<ILogger>(Logger);
serviceCollection.AddSingleton(FileSystemManager);
serviceCollection.AddSingleton<TvDbClientManager>();
@@ -762,7 +752,7 @@ namespace Emby.Server.Implementations
ProcessFactory,
LocalizationManager,
() => SubtitleEncoder,
- _configuration,
+ startupConfig,
StartupOptions.FFmpegPath);
serviceCollection.AddSingleton(MediaEncoder);
@@ -784,7 +774,7 @@ namespace Emby.Server.Implementations
this,
LoggerFactory.CreateLogger<HttpListenerHost>(),
ServerConfigurationManager,
- _configuration,
+ startupConfig,
NetworkManager,
JsonSerializer,
XmlSerializer,
@@ -1206,7 +1196,7 @@ namespace Emby.Server.Implementations
});
}
- protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(Logger);
+ protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(LoggerFactory.CreateLogger<WebSocketSharpListener>());
private CertificateInfo GetCertificateInfo(bool generateCertificate)
{