Register and construct IUserManager and IUserRepository correctly
This commit is contained in:
parent
84b48eb69c
commit
4daa5436fc
|
@ -246,12 +246,6 @@ namespace Emby.Server.Implementations
|
|||
/// <value>The server configuration manager.</value>
|
||||
public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user manager.
|
||||
/// </summary>
|
||||
/// <value>The user manager.</value>
|
||||
public IUserManager UserManager { get; set; }
|
||||
|
||||
public LocalizationManager LocalizationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -650,7 +644,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
serviceCollection.AddSingleton<IBlurayExaminer>(new BdInfoExaminer(FileSystemManager));
|
||||
|
||||
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
|
||||
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, Resolve<IUserManager>);
|
||||
serviceCollection.AddSingleton(UserDataManager);
|
||||
|
||||
_displayPreferencesRepository = new SqliteDisplayPreferencesRepository(
|
||||
|
@ -664,21 +658,11 @@ namespace Emby.Server.Implementations
|
|||
AuthenticationRepository = GetAuthenticationRepository();
|
||||
serviceCollection.AddSingleton(AuthenticationRepository);
|
||||
|
||||
_userRepository = GetUserRepository();
|
||||
serviceCollection.AddSingleton<IUserRepository, SqliteUserRepository>();
|
||||
|
||||
UserManager = new UserManager(
|
||||
LoggerFactory.CreateLogger<UserManager>(),
|
||||
_userRepository,
|
||||
XmlSerializer,
|
||||
NetworkManager,
|
||||
Resolve<IImageProcessor>,
|
||||
Resolve<IDtoService>,
|
||||
this,
|
||||
JsonSerializer,
|
||||
FileSystemManager,
|
||||
cryptoProvider);
|
||||
|
||||
serviceCollection.AddSingleton(UserManager);
|
||||
// TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
|
||||
serviceCollection.AddTransient(provider => new Lazy<IDtoService>(provider.GetRequiredService<IDtoService>));
|
||||
serviceCollection.AddSingleton<IUserManager, UserManager>();
|
||||
|
||||
// TODO: Add StartupOptions.FFmpegPath to IConfiguration so this doesn't need to be constructed manually
|
||||
serviceCollection.AddSingleton<IMediaEncoder>(new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
|
||||
|
@ -771,6 +755,7 @@ namespace Emby.Server.Implementations
|
|||
_sessionManager = Resolve<ISessionManager>();
|
||||
_httpServer = Resolve<IHttpServer>();
|
||||
|
||||
((SqliteUserRepository)Resolve<IUserRepository>()).Initialize();
|
||||
((ActivityRepository)Resolve<IActivityRepository>()).Initialize();
|
||||
_displayPreferencesRepository.Initialize();
|
||||
|
||||
|
@ -778,11 +763,12 @@ namespace Emby.Server.Implementations
|
|||
|
||||
SetStaticProperties();
|
||||
|
||||
((UserManager)UserManager).Initialize();
|
||||
var userManager = (UserManager)Resolve<IUserManager>();
|
||||
userManager.Initialize();
|
||||
|
||||
((UserDataManager)UserDataManager).Repository = userDataRepo;
|
||||
|
||||
((SqliteItemRepository)Resolve<IItemRepository>()).Initialize(userDataRepo, UserManager);
|
||||
((SqliteItemRepository)Resolve<IItemRepository>()).Initialize(userDataRepo, userManager);
|
||||
|
||||
FindParts();
|
||||
}
|
||||
|
@ -853,21 +839,6 @@ namespace Emby.Server.Implementations
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user repository.
|
||||
/// </summary>
|
||||
/// <returns><see cref="Task{SqliteUserRepository}" />.</returns>
|
||||
private SqliteUserRepository GetUserRepository()
|
||||
{
|
||||
var repo = new SqliteUserRepository(
|
||||
LoggerFactory.CreateLogger<SqliteUserRepository>(),
|
||||
ApplicationPaths);
|
||||
|
||||
repo.Initialize();
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
private IAuthenticationRepository GetAuthenticationRepository()
|
||||
{
|
||||
var repo = new AuthenticationRepository(LoggerFactory, ServerConfigurationManager);
|
||||
|
@ -889,7 +860,7 @@ namespace Emby.Server.Implementations
|
|||
BaseItem.ProviderManager = Resolve<IProviderManager>();
|
||||
BaseItem.LocalizationManager = LocalizationManager;
|
||||
BaseItem.ItemRepository = Resolve<IItemRepository>();
|
||||
User.UserManager = UserManager;
|
||||
User.UserManager = Resolve<IUserManager>();
|
||||
BaseItem.FileSystem = FileSystemManager;
|
||||
BaseItem.UserDataManager = UserDataManager;
|
||||
BaseItem.ChannelManager = Resolve<IChannelManager>();
|
||||
|
@ -984,7 +955,7 @@ namespace Emby.Server.Implementations
|
|||
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
|
||||
|
||||
Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
|
||||
UserManager.AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());
|
||||
Resolve<IUserManager>().AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());
|
||||
|
||||
IsoManager.AddParts(GetExports<IIsoMounter>());
|
||||
}
|
||||
|
|
|
@ -44,22 +44,14 @@ namespace Emby.Server.Implementations.Library
|
|||
{
|
||||
private readonly object _policySyncLock = new object();
|
||||
private readonly object _configSyncLock = new object();
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the active user repository.
|
||||
/// </summary>
|
||||
/// <value>The user repository.</value>
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly INetworkManager _networkManager;
|
||||
|
||||
private readonly Func<IImageProcessor> _imageProcessorFactory;
|
||||
private readonly Func<IDtoService> _dtoServiceFactory;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
private readonly Lazy<IDtoService> _dtoServiceFactory;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ICryptoProvider _cryptoProvider;
|
||||
|
@ -74,13 +66,15 @@ namespace Emby.Server.Implementations.Library
|
|||
private IPasswordResetProvider[] _passwordResetProviders;
|
||||
private DefaultPasswordResetProvider _defaultPasswordResetProvider;
|
||||
|
||||
private IDtoService DtoService => _dtoServiceFactory.Value;
|
||||
|
||||
public UserManager(
|
||||
ILogger<UserManager> logger,
|
||||
IUserRepository userRepository,
|
||||
IXmlSerializer xmlSerializer,
|
||||
INetworkManager networkManager,
|
||||
Func<IImageProcessor> imageProcessorFactory,
|
||||
Func<IDtoService> dtoServiceFactory,
|
||||
IImageProcessor imageProcessor,
|
||||
Lazy<IDtoService> dtoServiceFactory,
|
||||
IServerApplicationHost appHost,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
|
@ -90,7 +84,7 @@ namespace Emby.Server.Implementations.Library
|
|||
_userRepository = userRepository;
|
||||
_xmlSerializer = xmlSerializer;
|
||||
_networkManager = networkManager;
|
||||
_imageProcessorFactory = imageProcessorFactory;
|
||||
_imageProcessor = imageProcessor;
|
||||
_dtoServiceFactory = dtoServiceFactory;
|
||||
_appHost = appHost;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
|
@ -600,7 +594,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
try
|
||||
{
|
||||
_dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user);
|
||||
DtoService.AttachPrimaryImageAspectRatio(dto, user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -625,7 +619,7 @@ namespace Emby.Server.Implementations.Library
|
|||
{
|
||||
try
|
||||
{
|
||||
return _imageProcessorFactory().GetImageCacheTag(item, image);
|
||||
return _imageProcessor.GetImageCacheTag(item, image);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user