using System;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace StardewModdingAPI.Web.Framework
{
/// Provides comma-delimited model binds for mapping parameters.
/// Derived from .
public class CommaDelimitedModelBinderProvider : IModelBinderProvider
{
/*********
** Public methods
*********/
/// Creates a model binder based on the given context.
/// The model binding context.
public IModelBinder GetBinder(ModelBinderProviderContext context)
{
// validate
if (context == null)
throw new ArgumentNullException(nameof(context));
// get model binder
return context.Metadata.IsEnumerableType && !context.Metadata.ElementMetadata.IsComplexType
? new CommaDelimitedModelBinder()
: null;
}
}
}