aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Plugins/BasePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Plugins/BasePlugin.cs')
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs85
1 files changed, 35 insertions, 50 deletions
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index 705e15f17..23825db04 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -1,36 +1,12 @@
-using System;
-using System.IO;
-using MediaBrowser.Common.Kernel;
+using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.Plugins;
+using System;
+using System.IO;
namespace MediaBrowser.Common.Plugins
{
/// <summary>
- /// Provides a BasePlugin with generics, allowing for strongly typed configuration access.
- /// </summary>
- public abstract class BaseGenericPlugin<TConfigurationType> : BasePlugin
- where TConfigurationType : BasePluginConfiguration, new()
- {
- public new TConfigurationType Configuration
- {
- get
- {
- return base.Configuration as TConfigurationType;
- }
- set
- {
- base.Configuration = value;
- }
- }
-
- public override Type ConfigurationType
- {
- get { return typeof(TConfigurationType); }
- }
- }
-
- /// <summary>
/// Provides a common base class for all plugins
/// </summary>
public abstract class BasePlugin : IDisposable
@@ -50,7 +26,10 @@ namespace MediaBrowser.Common.Plugins
/// <summary>
/// Gets the type of configuration this plugin uses
/// </summary>
- public abstract Type ConfigurationType { get; }
+ public virtual Type ConfigurationType
+ {
+ get { return typeof (BasePluginConfiguration); }
+ }
/// <summary>
/// Gets the plugin version
@@ -74,20 +53,20 @@ namespace MediaBrowser.Common.Plugins
}
}
- private DateTime? _ConfigurationDateLastModified = null;
+ private DateTime? _configurationDateLastModified;
public DateTime ConfigurationDateLastModified
{
get
{
- if (_ConfigurationDateLastModified == null)
+ if (_configurationDateLastModified == null)
{
if (File.Exists(ConfigurationFilePath))
{
- _ConfigurationDateLastModified = File.GetLastWriteTimeUtc(ConfigurationFilePath);
+ _configurationDateLastModified = File.GetLastWriteTimeUtc(ConfigurationFilePath);
}
}
- return _ConfigurationDateLastModified ?? DateTime.MinValue;
+ return _configurationDateLastModified ?? DateTime.MinValue;
}
}
@@ -110,7 +89,13 @@ namespace MediaBrowser.Common.Plugins
/// <summary>
/// Gets the name of the configuration file. Subclasses should override
/// </summary>
- public virtual string ConfigurationFileName { get { return Name + ".xml"; } }
+ public virtual string ConfigurationFileName
+ {
+ get
+ {
+ return Name.Replace(" ", string.Empty) + ".xml";
+ }
+ }
/// <summary>
/// Gets the full path to the configuration file
@@ -123,7 +108,7 @@ namespace MediaBrowser.Common.Plugins
}
}
- private string _DataFolderPath = null;
+ private string _dataFolderPath;
/// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed
/// </summary>
@@ -131,19 +116,19 @@ namespace MediaBrowser.Common.Plugins
{
get
{
- if (_DataFolderPath == null)
+ if (_dataFolderPath == null)
{
// Give the folder name the same name as the config file name
// We can always make this configurable if/when needed
- _DataFolderPath = Path.Combine(Kernel.ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
+ _dataFolderPath = Path.Combine(Kernel.ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
- if (!Directory.Exists(_DataFolderPath))
+ if (!Directory.Exists(_dataFolderPath))
{
- Directory.CreateDirectory(_DataFolderPath);
+ Directory.CreateDirectory(_dataFolderPath);
}
}
- return _DataFolderPath;
+ return _dataFolderPath;
}
}
@@ -156,9 +141,9 @@ namespace MediaBrowser.Common.Plugins
}
/// <summary>
- /// Returns true or false indicating if the plugin should be downloaded and run within the UI.
+ /// Returns true or false indicating if the plugin should be downloaded and run within the Ui.
/// </summary>
- public virtual bool DownloadToUI
+ public virtual bool DownloadToUi
{
get
{
@@ -188,9 +173,9 @@ namespace MediaBrowser.Common.Plugins
{
InitializeOnServer();
}
- else if (kernel.KernelContext == KernelContext.UI)
+ else if (kernel.KernelContext == KernelContext.Ui)
{
- InitializeInUI();
+ InitializeInUi();
}
}
}
@@ -204,9 +189,9 @@ namespace MediaBrowser.Common.Plugins
}
/// <summary>
- /// Starts the plugin in the UI
+ /// Starts the plugin in the Ui
/// </summary>
- protected virtual void InitializeInUI()
+ protected virtual void InitializeInUi()
{
}
@@ -219,9 +204,9 @@ namespace MediaBrowser.Common.Plugins
{
DisposeOnServer();
}
- else if (Context == KernelContext.UI)
+ else if (Context == KernelContext.Ui)
{
- InitializeInUI();
+ InitializeInUi();
}
}
@@ -233,9 +218,9 @@ namespace MediaBrowser.Common.Plugins
}
/// <summary>
- /// Disposes the plugin in the UI
+ /// Disposes the plugin in the Ui
/// </summary>
- protected virtual void DisposeInUI()
+ protected virtual void DisposeInUi()
{
}
@@ -252,7 +237,7 @@ namespace MediaBrowser.Common.Plugins
}
// Reset this so it will be loaded again next time it's accessed
- _ConfigurationDateLastModified = null;
+ _configurationDateLastModified = null;
}
}
}