diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 0620469c0f..06b6fec555 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -119,17 +119,21 @@ namespace Emby.Server.Implementations
///
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{
- private SqliteUserRepository _userRepository;
+ private readonly IFileSystem _fileSystemManager;
+ private readonly INetworkManager _networkManager;
+ private readonly IXmlSerializer _xmlSerializer;
+ private readonly IStartupOptions _startupOptions;
+
private IMediaEncoder _mediaEncoder;
private ISessionManager _sessionManager;
private IHttpServer _httpServer;
private IHttpClient _httpClient;
+ private IInstallationManager _installationManager;
///
/// Gets a value indicating whether this instance can self restart.
///
- /// true if this instance can self restart; otherwise, false.
- public abstract bool CanSelfRestart { get; }
+ public bool CanSelfRestart => _startupOptions.RestartPath != null;
public virtual bool CanLaunchWebBrowser
{
@@ -140,7 +144,7 @@ namespace Emby.Server.Implementations
return false;
}
- if (StartupOptions.IsService)
+ if (_startupOptions.IsService)
{
return false;
}
@@ -210,8 +214,6 @@ namespace Emby.Server.Implementations
/// The configuration manager.
protected IConfigurationManager ConfigurationManager { get; set; }
- public IFileSystem FileSystemManager { get; set; }
-
///
public PackageVersionClass SystemUpdateLevel
{
@@ -246,18 +248,6 @@ namespace Emby.Server.Implementations
/// The server configuration manager.
public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
- ///
- /// Gets the installation manager.
- ///
- /// The installation manager.
- protected IInstallationManager InstallationManager { get; private set; }
-
- public IStartupOptions StartupOptions { get; }
-
- protected readonly IXmlSerializer XmlSerializer;
-
- protected INetworkManager NetworkManager { get; set; }
-
///
/// Initializes a new instance of the class.
///
@@ -268,24 +258,24 @@ namespace Emby.Server.Implementations
IFileSystem fileSystem,
INetworkManager networkManager)
{
- XmlSerializer = new MyXmlSerializer();
+ _xmlSerializer = new MyXmlSerializer();
- NetworkManager = networkManager;
+ _networkManager = networkManager;
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
ApplicationPaths = applicationPaths;
LoggerFactory = loggerFactory;
- FileSystemManager = fileSystem;
+ _fileSystemManager = fileSystem;
- ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
+ ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, _xmlSerializer, _fileSystemManager);
Logger = LoggerFactory.CreateLogger("App");
- StartupOptions = options;
+ _startupOptions = options;
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
- NetworkManager.NetworkChanged += OnNetworkChanged;
+ _networkManager.NetworkChanged += OnNetworkChanged;
CertificateInfo = new CertificateInfo
{
@@ -575,18 +565,18 @@ namespace Emby.Server.Implementations
return Logger;
});
- serviceCollection.AddSingleton(FileSystemManager);
+ serviceCollection.AddSingleton(_fileSystemManager);
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
- serviceCollection.AddSingleton(NetworkManager);
+ serviceCollection.AddSingleton(_networkManager);
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
- serviceCollection.AddSingleton(XmlSerializer);
+ serviceCollection.AddSingleton(_xmlSerializer);
serviceCollection.AddSingleton();
@@ -636,7 +626,7 @@ namespace Emby.Server.Implementations
provider.GetRequiredService(),
provider.GetRequiredService,
provider.GetRequiredService(),
- StartupOptions.FFmpegPath));
+ _startupOptions.FFmpegPath));
// TODO: Refactor to eliminate the circular dependencies here so that Lazy isn't required
serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService));
@@ -736,6 +726,8 @@ namespace Emby.Server.Implementations
var userDataRepo = (SqliteUserDataRepository)Resolve();
((SqliteItemRepository)Resolve()).Initialize(userDataRepo, userManager);
+ Resolve().PluginInstalled += PluginInstalled;
+
FindParts();
}
@@ -818,7 +810,7 @@ namespace Emby.Server.Implementations
BaseItem.LocalizationManager = Resolve();
BaseItem.ItemRepository = Resolve();
User.UserManager = Resolve();
- BaseItem.FileSystem = FileSystemManager;
+ BaseItem.FileSystem = _fileSystemManager;
BaseItem.UserDataManager = Resolve();
BaseItem.ChannelManager = Resolve();
Video.LiveTvManager = Resolve();
@@ -826,7 +818,7 @@ namespace Emby.Server.Implementations
UserView.TVSeriesManager = Resolve();
UserView.CollectionManager = Resolve();
BaseItem.MediaSourceManager = Resolve();
- CollectionFolder.XmlSerializer = XmlSerializer;
+ CollectionFolder.XmlSerializer = _xmlSerializer;
CollectionFolder.JsonSerializer = Resolve();
CollectionFolder.ApplicationHost = this;
AuthenticatedAttribute.AuthService = Resolve();
@@ -872,9 +864,6 @@ namespace Emby.Server.Implementations
///
private void FindParts()
{
- InstallationManager = ServiceProvider.GetService();
- InstallationManager.PluginInstalled += PluginInstalled;
-
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
{
ServerConfigurationManager.Configuration.IsPortAuthorized = true;
@@ -1210,7 +1199,7 @@ namespace Emby.Server.Implementations
IsShuttingDown = IsShuttingDown,
Version = ApplicationVersionString,
WebSocketPortNumber = HttpPort,
- CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
+ CompletedInstallations = _installationManager.CompletedInstallations.ToArray(),
Id = SystemId,
ProgramDataPath = ApplicationPaths.ProgramDataPath,
WebPath = ApplicationPaths.WebPath,
@@ -1233,12 +1222,12 @@ namespace Emby.Server.Implementations
EncoderLocation = _mediaEncoder.EncoderLocation,
SystemArchitecture = RuntimeInformation.OSArchitecture,
SystemUpdateLevel = SystemUpdateLevel,
- PackageName = StartupOptions.PackageName
+ PackageName = _startupOptions.PackageName
};
}
public IEnumerable GetWakeOnLanInfo()
- => NetworkManager.GetMacAddresses()
+ => _networkManager.GetMacAddresses()
.Select(i => new WakeOnLanInfo(i))
.ToList();
@@ -1350,7 +1339,7 @@ namespace Emby.Server.Implementations
if (addresses.Count == 0)
{
- addresses.AddRange(NetworkManager.GetLocalIpAddresses(ServerConfigurationManager.Configuration.IgnoreVirtualInterfaces));
+ addresses.AddRange(_networkManager.GetLocalIpAddresses(ServerConfigurationManager.Configuration.IgnoreVirtualInterfaces));
}
var resultList = new List();
@@ -1594,12 +1583,8 @@ namespace Emby.Server.Implementations
Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name);
}
}
-
- _userRepository?.Dispose();
}
- _userRepository = null;
-
_disposed = true;
}
}
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 227f1a5e7e..8db4146cd3 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.Data
private readonly IServerConfigurationManager _config;
private readonly IServerApplicationHost _appHost;
private readonly ILocalizationManager _localization;
- // TODO: Remove this dependency
+ // TODO: Remove this dependency. GetImageCacheTag() is the only method used and it can be converted to a static helper method
private readonly IImageProcessor _imageProcessor;
private readonly TypeMapper _typeMapper;
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index b35200e757..c3ac2ab411 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -36,9 +36,6 @@ namespace Jellyfin.Server
{
}
- ///
- public override bool CanSelfRestart => StartupOptions.RestartPath != null;
-
///
protected override void RestartInternal() => Program.Restart();