Skip to content

Instantly share code, notes, and snippets.

@codehaks
Created August 9, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehaks/0c2c7ebe3009b6a7012ad85a1dbda27b to your computer and use it in GitHub Desktop.
Save codehaks/0c2c7ebe3009b6a7012ad85a1dbda27b to your computer and use it in GitHub Desktop.
TagsModelBinderProvider
public class TagsModelBinderProvider:IModelBinderProvider
{
public IModelBinder GetBinder(ModelBinderProviderContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (context.Metadata.ModelType == typeof(IEnumerable<string>))
{
var binder = new BinderTypeModelBinder(typeof(TagsModelBinder));
return binder;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment