diff options
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
| -rw-r--r-- | Emby.Server.Implementations/ApplicationHost.cs | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index b9d38504c..5dcf42aae 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -303,7 +303,6 @@ namespace Emby.Server.Implementations /// <value>The user data repository.</value> private IUserDataManager UserDataManager { get; set; } private IUserRepository UserRepository { get; set; } - internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; } internal SqliteItemRepository ItemRepository { get; set; } private INotificationManager NotificationManager { get; set; } @@ -472,6 +471,7 @@ namespace Emby.Server.Implementations { try { + Logger.LogWarning("Creating instance of {Type}", type); return ActivatorUtilities.CreateInstance(_serviceProvider, type); } catch (Exception ex) @@ -525,29 +525,6 @@ namespace Emby.Server.Implementations return parts; } - public List<(T, string)> GetExportsWithInfo<T>(bool manageLifetime = true) - { - var parts = GetExportTypes<T>() - .Select(i => - { - var obj = CreateInstanceSafe(i); - - return ((T)obj, i.Assembly.Location); - }) - .Where(i => i.Item1 != null) - .ToList(); - - if (manageLifetime) - { - lock (DisposableParts) - { - DisposableParts.AddRange(parts.Select(i => i.Item1).OfType<IDisposable>()); - } - } - - return parts; - } - /// <summary> /// Runs the startup tasks. /// </summary> @@ -721,8 +698,7 @@ namespace Emby.Server.Implementations serviceCollection.AddSingleton(UserRepository); var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager); - DisplayPreferencesRepository = displayPreferencesRepo; - serviceCollection.AddSingleton(DisplayPreferencesRepository); + serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo); ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, assemblyInfo); serviceCollection.AddSingleton<IItemRepository>(ItemRepository); @@ -1085,7 +1061,10 @@ namespace Emby.Server.Implementations } ConfigurationManager.AddParts(GetExports<IConfigurationFactory>()); - Plugins = GetExportsWithInfo<IPlugin>().Select(LoadPlugin).Where(i => i != null).ToArray(); + Plugins = GetExports<IPlugin>() + .Select(LoadPlugin) + .Where(i => i != null) + .ToArray(); HttpServer.Init(GetExports<IService>(false), GetExports<IWebSocketListener>()); @@ -1119,19 +1098,15 @@ namespace Emby.Server.Implementations IsoManager.AddParts(GetExports<IIsoMounter>()); } - private IPlugin LoadPlugin((IPlugin, string) info) + private IPlugin LoadPlugin(IPlugin plugin) { - var plugin = info.Item1; - var assemblyFilePath = info.Item2; - try { - var assemblyPlugin = plugin as IPluginAssembly; - - if (assemblyPlugin != null) + if (plugin is IPluginAssembly assemblyPlugin) { var assembly = plugin.GetType().Assembly; var assemblyName = assembly.GetName(); + var assemblyFilePath = assembly.Location; var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath)); @@ -1401,7 +1376,7 @@ namespace Emby.Server.Implementations foreach (var file in Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)) { Logger.LogInformation("Loading assembly {Path}", file); - yield return Assembly.LoadFile(file); + yield return Assembly.LoadFrom(file); } } |
