39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
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
|
|
{
|
|
//=======================================================================
|
|
/// <summary>
|
|
/// Maps a browser request to a data object. Default class provides a base implementation of a model binder.
|
|
/// <para>Overridden to trim whitespace from input values.</para>
|
|
/// </summary>
|
|
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;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|