From 07791d46a571d3d6eed23e98ec0fe1c46ea0d37f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 23 Oct 2016 15:14:57 -0400 Subject: rework scheduled tasks in preparation of common project going portable --- MediaBrowser.Common/Plugins/BasePlugin.cs | 87 ++++++------------------------- 1 file changed, 17 insertions(+), 70 deletions(-) (limited to 'MediaBrowser.Common/Plugins/BasePlugin.cs') diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index b75accf9b..89ebeb6db 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -3,8 +3,6 @@ using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; using System; using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; namespace MediaBrowser.Common.Plugins { @@ -12,7 +10,7 @@ namespace MediaBrowser.Common.Plugins /// Provides a common base class for all plugins /// /// The type of the T configuration type. - public abstract class BasePlugin : IPlugin + public abstract class BasePlugin : IPlugin, IPluginAssembly where TConfigurationType : BasePluginConfiguration { /// @@ -57,69 +55,33 @@ namespace MediaBrowser.Common.Plugins get { return typeof(TConfigurationType); } } - /// - /// The _assembly name - /// - private AssemblyName _assemblyName; - /// - /// Gets the name of the assembly. - /// - /// The name of the assembly. - protected AssemblyName AssemblyName + public void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion, Guid assemblyId) { - get - { - return _assemblyName ?? (_assemblyName = GetType().Assembly.GetName()); - } - } + AssemblyFilePath = assemblyFilePath; + AssemblyFileName = assemblyFileName; + Version = assemblyVersion; + Id = assemblyId; - /// - /// The _unique id - /// - private Guid? _uniqueId; + IsFirstRun = !File.Exists(ConfigurationFilePath); + } /// /// Gets the unique id. /// /// The unique id. - public Guid Id - { - get - { - - if (!_uniqueId.HasValue) - { - var attribute = (GuidAttribute)GetType().Assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0]; - _uniqueId = new Guid(attribute.Value); - } - - return _uniqueId.Value; - } - } + public Guid Id { get; private set; } /// /// Gets the plugin version /// /// The version. - public Version Version - { - get - { - return AssemblyName.Version; - } - } + public Version Version { get; private set; } /// /// Gets the name the assembly file /// /// The name of the assembly file. - public string AssemblyFileName - { - get - { - return AssemblyName.Name + ".dll"; - } - } + protected string AssemblyFileName { get; private set; } /// /// Gets the last date modified of the configuration @@ -136,29 +98,11 @@ namespace MediaBrowser.Common.Plugins } } - /// - /// Gets the last date modified of the plugin - /// - /// The assembly date last modified. - public DateTime AssemblyDateLastModified - { - get - { - return File.GetLastWriteTimeUtc(AssemblyFilePath); - } - } - /// /// Gets the path to the assembly file /// /// The assembly file path. - public string AssemblyFilePath - { - get - { - return Path.Combine(ApplicationPaths.PluginsPath, AssemblyFileName); - } - } + public string AssemblyFilePath { get; private set; } /// /// The _configuration sync lock @@ -272,8 +216,6 @@ namespace MediaBrowser.Common.Plugins { ApplicationPaths = applicationPaths; XmlSerializer = xmlSerializer; - - IsFirstRun = !File.Exists(ConfigurationFilePath); } /// @@ -349,4 +291,9 @@ namespace MediaBrowser.Common.Plugins get { return Configuration; } } } + + public interface IPluginAssembly + { + void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion, Guid assemblyId); + } } -- cgit v1.2.3