jellyfin-server/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs

49 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.Net.Handlers;
2012-09-04 19:23:15 +00:00
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller;
using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Api.HttpHandlers
{
2012-09-02 05:30:25 +00:00
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
{
2012-09-04 19:23:15 +00:00
private BasePlugin _Plugin = null;
private BasePlugin Plugin
{
get
{
if (_Plugin == null)
{
string name = QueryString["assemblyfilename"];
_Plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));
}
return _Plugin;
}
}
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
{
2012-09-04 19:23:15 +00:00
return Task.FromResult<BasePluginConfiguration>(Plugin.Configuration);
}
2012-09-04 19:23:15 +00:00
public override TimeSpan CacheDuration
{
get
{
return TimeSpan.FromDays(7);
}
}
2012-08-22 02:50:59 +00:00
2012-09-04 19:23:15 +00:00
protected override Task<DateTime?> GetLastDateModified()
{
return Task.FromResult<DateTime?>(Plugin.ConfigurationDateLastModified);
}
2012-09-04 19:23:15 +00:00
}
}