mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
26 lines
681 B
C#
26 lines
681 B
C#
using System;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
|
using Newtonsoft.Json.Linq;
|
|
using OpenAuth.Mvc.Models;
|
|
|
|
namespace OpenAuth.Mvc
|
|
{
|
|
public class JsonBinderProvider : IModelBinderProvider
|
|
{
|
|
public IModelBinder GetBinder(ModelBinderProviderContext context)
|
|
{
|
|
if(context == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(context));
|
|
}
|
|
|
|
if (context.Metadata.ModelType == typeof(JObject))
|
|
{
|
|
return new BinderTypeModelBinder(typeof(JobjectModelBinder));
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |