Use .Distinct on assembly

This commit is contained in:
David Ullmer 2020-08-31 17:53:55 +02:00
parent 025ee2163f
commit 7f79f2ee0e
3 changed files with 10 additions and 8 deletions

View File

@ -1387,15 +1387,17 @@ namespace Emby.Server.Implementations
public IEnumerable<Assembly> GetApiPluginAssemblies()
{
var types = _allConcreteTypes
var assemblies = _allConcreteTypes
.Where(i => typeof(ControllerBase).IsAssignableFrom(i))
.Select(i => i.Assembly)
.Distinct();
foreach (var type in types)
foreach (var assembly in assemblies)
{
Logger.LogDebug("Found API endpoints in plugin {name}", type.Assembly.FullName);
yield return type.Assembly;
Logger.LogDebug("Found API endpoints in plugin {name}", assembly.FullName);
}
return assemblies;
}
public virtual void LaunchUrl(string url)

View File

@ -136,9 +136,9 @@ namespace Jellyfin.Server.Extensions
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="baseUrl">The base url for the API.</param>
/// <param name="applicationHost">The application host.</param>
/// <param name="pluginAssemblies">An IEnumberable containing all plugin assemblies with API controllers.</param>
/// <returns>The MVC builder.</returns>
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IApplicationHost applicationHost)
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IEnumerable<Assembly> pluginAssemblies)
{
IMvcBuilder mvcBuilder = serviceCollection
.AddCors(options =>
@ -179,7 +179,7 @@ namespace Jellyfin.Server.Extensions
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
});
foreach (Assembly pluginAssembly in applicationHost.GetApiPluginAssemblies())
foreach (Assembly pluginAssembly in pluginAssemblies)
{
mvcBuilder.AddApplicationPart(pluginAssembly);
}

View File

@ -41,7 +41,7 @@ namespace Jellyfin.Server
{
services.AddResponseCompression();
services.AddHttpContextAccessor();
services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost);
services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost.GetApiPluginAssemblies());
services.AddJellyfinApiSwagger();