<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />

DynamicUtils

static class DynamicUtils
using Microsoft.CSharp.RuntimeBinder; using System; using System.Collections.Generic; using System.Dynamic; using System.Linq.Expressions; using System.Runtime.CompilerServices; namespace Newtonsoft.Json.Utilities { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal static class DynamicUtils { [System.Runtime.CompilerServices.Nullable(0)] internal static class BinderWrapper { public static CallSiteBinder GetMember(string name, Type context) { return Binder.GetMember(CSharpBinderFlags.None, name, context, new CSharpArgumentInfo[1] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }); } public static CallSiteBinder SetMember(string name, Type context) { return Binder.SetMember(CSharpBinderFlags.None, name, context, new CSharpArgumentInfo[2] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null) }); } } public static IEnumerable<string> GetDynamicMemberNames(this IDynamicMetaObjectProvider dynamicProvider) { return dynamicProvider.GetMetaObject(Expression.Constant(dynamicProvider)).GetDynamicMemberNames(); } } }