mirror of https://github.com/jellyfin/jellyfin.git
feat: implement CommaDelimitedArrayModelBinderProvider
This commit is contained in:
parent
4b4c74bdcd
commit
9aad772288
|
@ -379,7 +379,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
public ActionResult PostCapabilities(
|
public ActionResult PostCapabilities(
|
||||||
[FromQuery] string? id,
|
[FromQuery] string? id,
|
||||||
[FromQuery] string? playableMediaTypes,
|
[FromQuery] string? playableMediaTypes,
|
||||||
[FromQuery][ModelBinder(typeof(CommaDelimitedArrayModelBinder))] GeneralCommandType[] supportedCommands,
|
[FromQuery] GeneralCommandType[] supportedCommands,
|
||||||
[FromQuery] bool supportsMediaControl = false,
|
[FromQuery] bool supportsMediaControl = false,
|
||||||
[FromQuery] bool supportsSync = false,
|
[FromQuery] bool supportsSync = false,
|
||||||
[FromQuery] bool supportsPersistentIdentifier = true)
|
[FromQuery] bool supportsPersistentIdentifier = true)
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
|
||||||
|
namespace Jellyfin.Api.ModelBinders
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Comma delimited array model binder provider.
|
||||||
|
/// </summary>
|
||||||
|
public class CommaDelimitedArrayModelBinderProvider : IModelBinderProvider
|
||||||
|
{
|
||||||
|
private readonly IModelBinder _binder;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="CommaDelimitedArrayModelBinderProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public CommaDelimitedArrayModelBinderProvider()
|
||||||
|
{
|
||||||
|
_binder = new CommaDelimitedArrayModelBinder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IModelBinder? GetBinder(ModelBinderProviderContext context)
|
||||||
|
{
|
||||||
|
return context.Metadata.ModelType.IsArray ? _binder : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ using Jellyfin.Api.Auth.LocalAccessPolicy;
|
||||||
using Jellyfin.Api.Auth.RequiresElevationPolicy;
|
using Jellyfin.Api.Auth.RequiresElevationPolicy;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Controllers;
|
using Jellyfin.Api.Controllers;
|
||||||
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Server.Configuration;
|
using Jellyfin.Server.Configuration;
|
||||||
using Jellyfin.Server.Filters;
|
using Jellyfin.Server.Filters;
|
||||||
using Jellyfin.Server.Formatters;
|
using Jellyfin.Server.Formatters;
|
||||||
|
@ -166,6 +167,8 @@ namespace Jellyfin.Server.Extensions
|
||||||
|
|
||||||
opts.OutputFormatters.Add(new CssOutputFormatter());
|
opts.OutputFormatters.Add(new CssOutputFormatter());
|
||||||
opts.OutputFormatters.Add(new XmlOutputFormatter());
|
opts.OutputFormatters.Add(new XmlOutputFormatter());
|
||||||
|
|
||||||
|
opts.ModelBinderProviders.Insert(0, new CommaDelimitedArrayModelBinderProvider());
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clear app parts to avoid other assemblies being picked up
|
// Clear app parts to avoid other assemblies being picked up
|
||||||
|
|
Loading…
Reference in New Issue