From 31357d3298baa8e0f540dfefc47eb39da8df128d Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Mon, 3 Sep 2012 12:40:35 -0400 Subject: Updated plugins to store their assemblies directly in the plugins folder --- MediaBrowser.Common/Kernel/BaseKernel.cs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'MediaBrowser.Common/Kernel/BaseKernel.cs') diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs index cdde17b24..4f1bdae6b 100644 --- a/MediaBrowser.Common/Kernel/BaseKernel.cs +++ b/MediaBrowser.Common/Kernel/BaseKernel.cs @@ -50,9 +50,9 @@ namespace MediaBrowser.Common.Kernel } /// - /// Gets the kernel context. The UI kernel will have to override this. + /// Gets the kernel context. Subclasses will have to override. /// - protected KernelContext KernelContext { get { return KernelContext.Server; } } + public abstract KernelContext KernelContext { get; } public BaseKernel() { @@ -104,7 +104,7 @@ namespace MediaBrowser.Common.Kernel // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that // This will prevent the .dll file from getting locked, and allow us to replace it when needed - IEnumerable pluginAssemblies = Directory.GetFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.AllDirectories).Select(f => Assembly.Load(File.ReadAllBytes((f)))); + IEnumerable pluginAssemblies = Directory.GetFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly).Select(f => Assembly.Load(File.ReadAllBytes((f)))); var catalog = new AggregateCatalog(pluginAssemblies.Select(a => new AssemblyCatalog(a))); @@ -144,20 +144,7 @@ namespace MediaBrowser.Common.Kernel { foreach (BasePlugin plugin in Plugins) { - Assembly assembly = plugin.GetType().Assembly; - AssemblyName assemblyName = assembly.GetName(); - - plugin.Version = assemblyName.Version; - plugin.Path = Path.Combine(ApplicationPaths.PluginsPath, assemblyName.Name); - - plugin.Context = KernelContext; - - plugin.ReloadConfiguration(); - - if (plugin.Enabled) - { - plugin.Init(); - } + plugin.Initialize(this); } } @@ -276,10 +263,18 @@ namespace MediaBrowser.Common.Kernel return GetType().Assembly.GetName().Version; } } + + BaseApplicationPaths IKernel.ApplicationPaths + { + get { return ApplicationPaths; } + } } public interface IKernel { + BaseApplicationPaths ApplicationPaths { get; } + KernelContext KernelContext { get; } + Task Init(IProgress progress); void Dispose(); } -- cgit v1.2.3