aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinderProvider.cs
blob: b9785a73b833e11f31cdc22de32bad7f20845129 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
        }
    }
}