mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-08-11 09:13:54 -04:00
Add plugin assemblies to mvc builder
This commit is contained in:
parent
98d1d2325d
commit
9e95fe8f9d
@ -53,7 +53,6 @@ using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Chapters;
|
||||
using MediaBrowser.Controller.Collections;
|
||||
@ -98,6 +97,7 @@ using MediaBrowser.Providers.Plugins.TheTvdb;
|
||||
using MediaBrowser.Providers.Subtitles;
|
||||
using MediaBrowser.XbmcMetadata.Providers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Prometheus.DotNetRuntime;
|
||||
@ -1385,6 +1385,29 @@ namespace Emby.Server.Implementations
|
||||
_plugins = list.ToArray();
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> GetApiPluginAssemblies()
|
||||
{
|
||||
var assemblies = new List<Assembly>();
|
||||
try
|
||||
{
|
||||
var types = _allConcreteTypes
|
||||
.Where(i => typeof(ControllerBase).IsAssignableFrom(i))
|
||||
// .Select(i => ActivatorUtilities.CreateInstance(ServiceProvider, i))
|
||||
.ToArray();
|
||||
|
||||
foreach (var variable in types)
|
||||
{
|
||||
assemblies.Add(variable.Assembly);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return assemblies;
|
||||
}
|
||||
|
||||
public virtual void LaunchUrl(string url)
|
||||
{
|
||||
if (!CanLaunchWebBrowser)
|
||||
|
@ -20,8 +20,6 @@ using Jellyfin.Server.Formatters;
|
||||
using Jellyfin.Server.Models;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Json;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -179,18 +177,14 @@ namespace Jellyfin.Server.Extensions
|
||||
|
||||
// From JsonDefaults.PascalCase
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
|
||||
})
|
||||
.AddControllersAsServices();
|
||||
});
|
||||
|
||||
if (applicationHost.Plugins != null)
|
||||
foreach (Assembly pluginAssembly in applicationHost.GetApiPluginAssemblies())
|
||||
{
|
||||
foreach (IPlugin plugin in applicationHost.Plugins)
|
||||
{
|
||||
mvcBuilder.AddApplicationPart(plugin.GetType().Assembly);
|
||||
}
|
||||
mvcBuilder.AddApplicationPart(pluginAssembly);
|
||||
}
|
||||
|
||||
return mvcBuilder;
|
||||
return mvcBuilder.AddControllersAsServices();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -76,6 +77,12 @@ namespace MediaBrowser.Common
|
||||
/// <value>The plugins.</value>
|
||||
IReadOnlyList<IPlugin> Plugins { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all plugin assemblies which implement a custom rest api.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable{Assembly}"/> containing the plugin assemblies.</returns>
|
||||
IEnumerable<Assembly> GetApiPluginAssemblies();
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the pending restart.
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user