Merge branch 'master' into warn17

This commit is contained in:
Bond-009
2020-03-11 20:26:43 +01:00
committed by GitHub
197 changed files with 2620 additions and 2176 deletions

View File

@@ -118,7 +118,6 @@ namespace Emby.Server.Implementations
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{
private SqliteUserRepository _userRepository;
private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
/// <summary>
@@ -166,10 +165,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;
@@ -180,10 +178,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.
@@ -327,8 +324,6 @@ namespace Emby.Server.Implementations
private IMediaSourceManager MediaSourceManager { get; set; }
private readonly IConfiguration _configuration;
/// <summary>
/// Gets the installation manager.
/// </summary>
@@ -366,11 +361,8 @@ namespace Emby.Server.Implementations
IStartupOptions options,
IFileSystem fileSystem,
IImageEncoder imageEncoder,
INetworkManager networkManager,
IConfiguration configuration)
INetworkManager networkManager)
{
_configuration = configuration;
XmlSerializer = new MyXmlSerializer();
NetworkManager = networkManager;
@@ -586,7 +578,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;
@@ -619,7 +612,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))
@@ -651,14 +644,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();
@@ -667,13 +660,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>();
@@ -761,7 +751,7 @@ namespace Emby.Server.Implementations
ProcessFactory,
LocalizationManager,
() => SubtitleEncoder,
_configuration,
startupConfig,
StartupOptions.FFmpegPath);
serviceCollection.AddSingleton(MediaEncoder);
@@ -783,7 +773,7 @@ namespace Emby.Server.Implementations
this,
LoggerFactory.CreateLogger<HttpListenerHost>(),
ServerConfigurationManager,
_configuration,
startupConfig,
NetworkManager,
JsonSerializer,
XmlSerializer,
@@ -846,7 +836,10 @@ namespace Emby.Server.Implementations
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
serviceCollection.AddSingleton(UserViewManager);
NotificationManager = new NotificationManager(LoggerFactory, UserManager, ServerConfigurationManager);
NotificationManager = new NotificationManager(
LoggerFactory.CreateLogger<NotificationManager>(),
UserManager,
ServerConfigurationManager);
serviceCollection.AddSingleton(NotificationManager);
serviceCollection.AddSingleton<IDeviceDiscovery>(new DeviceDiscovery(ServerConfigurationManager));
@@ -1202,7 +1195,7 @@ namespace Emby.Server.Implementations
});
}
protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(Logger);
protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(LoggerFactory.CreateLogger<WebSocketSharpListener>());
private CertificateInfo GetCertificateInfo(bool generateCertificate)
{