| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using MediaBrowser.Common.Json;
- namespace MediaBrowser.Common.Plugins
- {
- public abstract class BasePlugin<TConfigurationType> : IPlugin
- where TConfigurationType : BasePluginConfiguration, new()
- {
- public string Path { get; set; }
- public TConfigurationType Configuration { get; private set; }
- private string ConfigurationPath
- {
- get
- {
- return System.IO.Path.Combine(Path, "config.js");
- }
- }
-
- public void Init()
- {
- Configuration = GetConfiguration();
- if (Configuration.Enabled)
- {
- InitInternal();
- }
- }
- protected abstract void InitInternal();
- private TConfigurationType GetConfiguration()
- {
- if (!File.Exists(ConfigurationPath))
- {
- return new TConfigurationType();
- }
- return JsonSerializer.Deserialize<TConfigurationType>(ConfigurationPath);
- }
- }
- public interface IPlugin
- {
- string Path { get; set; }
- void Init();
- }
- }
|