Replaced injections of ILogger with ILoggerFactory

This makes resolving dependencies from the container much easier as
you cannot resolve with primitives parameters in a way that is any
more readable.

The aim of this commit is to change as little as possible with the end
result, loggers that were newed up for the parent object were given the same
name. Objects that used the base or app loggers, were given a new logger with
an appropriate name.

Also removed some unused dependencies.
This commit is contained in:
William Taylor
2019-01-17 22:55:05 +00:00
parent 0586598d33
commit 65cd3ed597
42 changed files with 296 additions and 163 deletions

View File

@@ -20,8 +20,8 @@ namespace Emby.Server.Implementations.Data
{
protected IFileSystem FileSystem { get; private set; }
public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
: base(logger)
public SqliteDisplayPreferencesRepository(ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
: base(loggerFactory.CreateLogger(nameof(SqliteDisplayPreferencesRepository)))
{
_jsonSerializer = jsonSerializer;
FileSystem = fileSystem;

View File

@@ -67,8 +67,16 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
/// </summary>
public SqliteItemRepository(IServerConfigurationManager config, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, ILogger logger, IAssemblyInfo assemblyInfo, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, ITimerFactory timerFactory)
: base(logger)
public SqliteItemRepository(
IServerConfigurationManager config,
IServerApplicationHost appHost,
IJsonSerializer jsonSerializer,
ILoggerFactory loggerFactory,
IAssemblyInfo assemblyInfo,
IFileSystem fileSystem,
IEnvironmentInfo environmentInfo,
ITimerFactory timerFactory)
: base(loggerFactory.CreateLogger(nameof(SqliteItemRepository)))
{
if (config == null)
{

View File

@@ -15,12 +15,11 @@ namespace Emby.Server.Implementations.Data
{
public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
{
private readonly IFileSystem _fileSystem;
public SqliteUserDataRepository(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem)
: base(logger)
public SqliteUserDataRepository(
ILoggerFactory loggerFactory,
IApplicationPaths appPaths)
: base(loggerFactory.CreateLogger(nameof(SqliteUserDataRepository)))
{
_fileSystem = fileSystem;
DbFilePath = Path.Combine(appPaths.DataPath, "library.db");
}

View File

@@ -17,8 +17,11 @@ namespace Emby.Server.Implementations.Data
{
private readonly IJsonSerializer _jsonSerializer;
public SqliteUserRepository(ILogger logger, IServerApplicationPaths appPaths, IJsonSerializer jsonSerializer)
: base(logger)
public SqliteUserRepository(
ILoggerFactory loggerFactory,
IServerApplicationPaths appPaths,
IJsonSerializer jsonSerializer)
: base(loggerFactory.CreateLogger(nameof(SqliteUserRepository)))
{
_jsonSerializer = jsonSerializer;