< Summary - Jellyfin

Information
Class: MediaBrowser.Common.Plugins.BasePlugin
Assembly: MediaBrowser.Common
File(s): /srv/git/jellyfin/MediaBrowser.Common/Plugins/BasePlugin.cs
Line coverage
76%
Covered lines: 13
Uncovered lines: 4
Coverable lines: 17
Total lines: 94
Line coverage: 76.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Description()100%210%
get_CanUninstall()100%11100%
GetPluginInfo()100%11100%
OnUninstalling()100%210%
SetAttributes(...)100%11100%
SetId(...)100%210%

File(s)

/srv/git/jellyfin/MediaBrowser.Common/Plugins/BasePlugin.cs

#LineLine coverage
 1#nullable disable
 2
 3using System;
 4using System.IO;
 5using System.Reflection;
 6using MediaBrowser.Model.Plugins;
 7
 8namespace MediaBrowser.Common.Plugins
 9{
 10    /// <summary>
 11    /// Provides a common base class for all plugins.
 12    /// </summary>
 13    public abstract class BasePlugin : IPlugin, IPluginAssembly
 14    {
 15        /// <summary>
 16        /// Gets the name of the plugin.
 17        /// </summary>
 18        /// <value>The name.</value>
 19        public abstract string Name { get; }
 20
 21        /// <summary>
 22        /// Gets the description.
 23        /// </summary>
 24        /// <value>The description.</value>
 025        public virtual string Description => string.Empty;
 26
 27        /// <summary>
 28        /// Gets the unique id.
 29        /// </summary>
 30        /// <value>The unique id.</value>
 31        public virtual Guid Id { get; private set; }
 32
 33        /// <summary>
 34        /// Gets the plugin version.
 35        /// </summary>
 36        /// <value>The version.</value>
 37        public Version Version { get; private set; }
 38
 39        /// <summary>
 40        /// Gets the path to the assembly file.
 41        /// </summary>
 42        /// <value>The assembly file path.</value>
 43        public string AssemblyFilePath { get; private set; }
 44
 45        /// <summary>
 46        /// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
 47        /// </summary>
 48        /// <value>The data folder path.</value>
 49        public string DataFolderPath { get; private set; }
 50
 51        /// <summary>
 52        /// Gets a value indicating whether the plugin can be uninstalled.
 53        /// </summary>
 754        public bool CanUninstall => !Path.GetDirectoryName(AssemblyFilePath)
 755            .Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.Ordinal);
 56
 57        /// <summary>
 58        /// Gets the plugin info.
 59        /// </summary>
 60        /// <returns>PluginInfo.</returns>
 61        public virtual PluginInfo GetPluginInfo()
 62        {
 763            var info = new PluginInfo(
 764                Name,
 765                Version,
 766                Description,
 767                Id,
 768                CanUninstall);
 69
 770            return info;
 71        }
 72
 73        /// <summary>
 74        /// Called just before the plugin is uninstalled from the server.
 75        /// </summary>
 76        public virtual void OnUninstalling()
 77        {
 078        }
 79
 80        /// <inheritdoc />
 81        public void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion)
 82        {
 15483            AssemblyFilePath = assemblyFilePath;
 15484            DataFolderPath = dataFolderPath;
 15485            Version = assemblyVersion;
 15486        }
 87
 88        /// <inheritdoc />
 89        public void SetId(Guid assemblyId)
 90        {
 091            Id = assemblyId;
 092        }
 93    }
 94}