aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Plugins/PluginManager.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2022-12-07 17:40:24 +0100
committerShadowghost <Ghost_of_Stone@web.de>2022-12-07 17:40:24 +0100
commit2c86bd1875e6e85d5867618e992d850453dae663 (patch)
tree671070fb246fd3821bf6f1e58a01c402a2f969d1 /Emby.Server.Implementations/Plugins/PluginManager.cs
parentdd5f90802e71083347b6095eb79a9de0b9d34615 (diff)
parent3cb7fe50127b1a8158186b390836ee25ae5a50fd (diff)
Merge branch 'master' into network-rewrite
Diffstat (limited to 'Emby.Server.Implementations/Plugins/PluginManager.cs')
-rw-r--r--Emby.Server.Implementations/Plugins/PluginManager.cs23
1 files changed, 10 insertions, 13 deletions
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index 3f7d46822..14e7c2269 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Plugins
foreach (var pluginServiceRegistrator in _appHost.GetExportTypes<IPluginServiceRegistrator>())
{
var plugin = GetPluginByAssembly(pluginServiceRegistrator.Assembly);
- if (plugin == null)
+ if (plugin is null)
{
_logger.LogError("Unable to find plugin in assembly {Assembly}", pluginServiceRegistrator.Assembly.FullName);
continue;
@@ -210,10 +210,7 @@ namespace Emby.Server.Implementations.Plugins
/// <param name="folder">Folder of the plugin.</param>
public void ImportPluginFrom(string folder)
{
- if (string.IsNullOrEmpty(folder))
- {
- throw new ArgumentNullException(nameof(folder));
- }
+ ArgumentException.ThrowIfNullOrEmpty(folder);
// Load the plugin.
var plugin = LoadManifest(folder);
@@ -263,12 +260,12 @@ namespace Emby.Server.Implementations.Plugins
{
LocalPlugin? plugin;
- if (version == null)
+ if (version is null)
{
// If no version is given, return the current instance.
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
- plugin = plugins.FirstOrDefault(p => p.Instance != null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
+ plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
}
else
{
@@ -320,7 +317,7 @@ namespace Emby.Server.Implementations.Plugins
ArgumentNullException.ThrowIfNull(assembly);
var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location));
- if (plugin == null)
+ if (plugin is null)
{
// A plugin's assembly didn't cause this issue, so ignore it.
return;
@@ -442,7 +439,7 @@ namespace Emby.Server.Implementations.Plugins
_logger.LogDebug("Creating instance of {Type}", type);
// _appHost.ServiceProvider is already assigned when we create the plugins
var instance = (IPlugin)ActivatorUtilities.CreateInstance(_appHost.ServiceProvider!, type);
- if (plugin == null)
+ if (plugin is null)
{
// Create a dummy record for the providers.
// TODO: remove this code once all provided have been released as separate plugins.
@@ -500,7 +497,7 @@ namespace Emby.Server.Implementations.Plugins
#pragma warning restore CA1031 // Do not catch general exception types
{
_logger.LogError(ex, "Error creating {Type}", type.FullName);
- if (plugin != null)
+ if (plugin is not null)
{
if (ChangePluginState(plugin, PluginStatus.Malfunctioned))
{
@@ -523,7 +520,7 @@ namespace Emby.Server.Implementations.Plugins
var predecessor = _plugins.OrderByDescending(p => p.Version)
.FirstOrDefault(p => p.Id.Equals(plugin.Id) && p.IsEnabledAndSupported && p.Version != plugin.Version);
- if (predecessor != null)
+ if (predecessor is not null)
{
return;
}
@@ -577,7 +574,7 @@ namespace Emby.Server.Implementations.Plugins
_logger.LogError(ex, "Error deserializing {Json}.", Encoding.UTF8.GetString(data!));
}
- if (manifest != null)
+ if (manifest is not null)
{
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
{
@@ -711,7 +708,7 @@ namespace Emby.Server.Implementations.Plugins
&& p.IsEnabledAndSupported
&& p.Version != plugin.Version);
- if (previousVersion == null)
+ if (previousVersion is null)
{
// This value is memory only - so that the web will show restart required.
plugin.Manifest.Status = PluginStatus.Restart;