From 507beb76f634eb5d3e84056d9c635bfc9188f41b Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Thu, 6 Sep 2012 10:18:54 -0400 Subject: Added context-sensitive init/dispose methods for plugins --- MediaBrowser.Common/Plugins/BasePlugin.cs | 44 ++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Common/Plugins/BasePlugin.cs') diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index 55f0926662..705e15f173 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -184,22 +184,58 @@ namespace MediaBrowser.Common.Plugins if (Enabled) { - InitializeInternal(); + if (kernel.KernelContext == KernelContext.Server) + { + InitializeOnServer(); + } + else if (kernel.KernelContext == KernelContext.UI) + { + InitializeInUI(); + } } } } /// - /// Starts the plugin. + /// Starts the plugin on the server + /// + protected virtual void InitializeOnServer() + { + } + + /// + /// Starts the plugin in the UI /// - protected virtual void InitializeInternal() + protected virtual void InitializeInUI() { } /// /// Disposes the plugins. Undos all actions performed during Init. /// - public virtual void Dispose() + public void Dispose() + { + if (Context == KernelContext.Server) + { + DisposeOnServer(); + } + else if (Context == KernelContext.UI) + { + InitializeInUI(); + } + } + + /// + /// Disposes the plugin on the server + /// + protected virtual void DisposeOnServer() + { + } + + /// + /// Disposes the plugin in the UI + /// + protected virtual void DisposeInUI() { } -- cgit v1.2.3