Added context-sensitive init/dispose methods for plugins
This commit is contained in:
parent
908695d88a
commit
507beb76f6
|
@ -18,7 +18,7 @@ namespace MediaBrowser.Api
|
|||
get { return "Media Browser API"; }
|
||||
}
|
||||
|
||||
protected override void InitializeInternal()
|
||||
protected override void InitializeOnServer()
|
||||
{
|
||||
var httpServer = Kernel.Instance.HttpServer;
|
||||
|
||||
|
|
|
@ -184,22 +184,58 @@ namespace MediaBrowser.Common.Plugins
|
|||
|
||||
if (Enabled)
|
||||
{
|
||||
InitializeInternal();
|
||||
if (kernel.KernelContext == KernelContext.Server)
|
||||
{
|
||||
InitializeOnServer();
|
||||
}
|
||||
else if (kernel.KernelContext == KernelContext.UI)
|
||||
{
|
||||
InitializeInUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the plugin.
|
||||
/// Starts the plugin on the server
|
||||
/// </summary>
|
||||
protected virtual void InitializeInternal()
|
||||
protected virtual void InitializeOnServer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the plugin in the UI
|
||||
/// </summary>
|
||||
protected virtual void InitializeInUI()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the plugins. Undos all actions performed during Init.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
if (Context == KernelContext.Server)
|
||||
{
|
||||
DisposeOnServer();
|
||||
}
|
||||
else if (Context == KernelContext.UI)
|
||||
{
|
||||
InitializeInUI();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the plugin on the server
|
||||
/// </summary>
|
||||
protected virtual void DisposeOnServer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the plugin in the UI
|
||||
/// </summary>
|
||||
protected virtual void DisposeInUI()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace MediaBrowser.TV
|
|||
get { return "TV"; }
|
||||
}
|
||||
|
||||
protected override void InitializeInternal()
|
||||
protected override void InitializeOnServer()
|
||||
{
|
||||
Kernel.Instance.ItemController.PreBeginResolvePath += ItemController_PreBeginResolvePath;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
protected override void DisposeOnServer()
|
||||
{
|
||||
Kernel.Instance.ItemController.PreBeginResolvePath -= ItemController_PreBeginResolvePath;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user