using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Sarand.OperationsMgr.Web.System { //======================================================================= /// /// Maps a browser request to a data object. Default class provides a base implementation of a model binder. /// Overridden to trim whitespace from input values. /// public class OpnModelBinderProvider : IModelBinderProvider { //------------------------------------------------------------------- public OpnModelBinderProvider () { } //------------------------------------------------------------------- public IModelBinder GetBinder (ModelBinderProviderContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); // Intercept String form values. if (context.Metadata.ModelType == typeof(string)) return new BinderTypeModelBinder(typeof(OpnModelBinder)); // Default - return null so that default binding provider is used. return null; } //------------------------------------------------------------------- } //======================================================================= }