mirror of
https://gitee.com/iioter/iotgateway.git
synced 2024-12-04 12:48:16 +08:00
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
|
using System;
|
|
using System.Collections;
|
|
using WalkingTec.Mvvm.Core;
|
|
|
|
namespace WalkingTec.Mvvm.Mvc.Binders
|
|
{
|
|
/// <summary>
|
|
/// CustomBinderProvider
|
|
/// </summary>
|
|
public class StringBinderProvider : IModelBinderProvider
|
|
{
|
|
/// <summary>
|
|
/// GetBinder
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
public IModelBinder GetBinder(ModelBinderProviderContext context)
|
|
{
|
|
if (context == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(context));
|
|
}
|
|
|
|
if (context.Metadata.ModelType == typeof(DateRange))
|
|
return new BinderTypeModelBinder(typeof(DateRangeBinder));
|
|
|
|
if (context.Metadata.ModelType == typeof(string))
|
|
{
|
|
return new BinderTypeModelBinder(typeof(StringIgnoreLTGTBinder));
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|