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

54 lines
1.6 KiB
C#
Raw Normal View History

using MediaBrowser.Common.Net.Handlers;
2012-09-04 19:23:15 +00:00
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller;
using MediaBrowser.Model.Plugins;
using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
2012-09-02 05:30:25 +00:00
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("pluginconfiguration", request);
}
2012-09-11 18:20:12 +00:00
private BasePlugin _plugin;
2012-09-04 19:23:15 +00:00
private BasePlugin Plugin
{
get
{
2012-09-11 18:20:12 +00:00
if (_plugin == null)
2012-09-04 19:23:15 +00:00
{
string name = QueryString["assemblyfilename"];
2012-09-11 18:20:12 +00:00
_plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));
2012-09-04 19:23:15 +00:00
}
2012-09-11 18:20:12 +00:00
return _plugin;
2012-09-04 19:23:15 +00:00
}
}
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
{
2012-09-11 18:20:12 +00:00
return Task.FromResult(Plugin.Configuration);
2012-09-04 19:23:15 +00:00
}
protected override async Task<ResponseInfo> GetResponseInfo()
2012-09-04 19:23:15 +00:00
{
var info = await base.GetResponseInfo().ConfigureAwait(false);
2012-08-22 02:50:59 +00:00
info.DateLastModified = Plugin.ConfigurationDateLastModified;
2012-09-04 19:23:15 +00:00
info.CacheDuration = TimeSpan.FromDays(7);
return info;
}
}
}