<PackageReference Include="Microsoft.CSharp" Version="4.4.1" />

CSharpGetIndexBinder

using Microsoft.CSharp.RuntimeBinder.Semantics; using System; using System.Collections.Generic; using System.Dynamic; namespace Microsoft.CSharp.RuntimeBinder { internal sealed class CSharpGetIndexBinder : GetIndexBinder, ICSharpBinder { private readonly List<CSharpArgumentInfo> _argumentInfo; private readonly RuntimeBinder _binder; public string Name => "$Item$"; public BindingFlag BindingFlags => BindingFlag.BIND_RVALUEREQUIRED; public bool IsBinderThatCanHaveRefReceiver => true; public Type CallingContext { get; } public bool IsChecked => false; public Expr DispatchPayload(RuntimeBinder runtimeBinder, ArgumentObject[] arguments, LocalVariableSymbol[] locals) { Expr optionalIndexerArguments = runtimeBinder.CreateArgumentListEXPR(arguments, locals, 1, arguments.Length); return runtimeBinder.BindProperty(this, arguments[0], locals[0], optionalIndexerArguments, false); } public void PopulateSymbolTableWithName(SymbolTable symbolTable, Type callingType, ArgumentObject[] arguments) { symbolTable.PopulateSymbolTableWithName("$Item$", null, arguments[0].Type); } CSharpArgumentInfo ICSharpBinder.GetArgumentInfo(int index) { return _argumentInfo[index]; } public CSharpGetIndexBinder(Type callingContext, IEnumerable<CSharpArgumentInfo> argumentInfo) : base(BinderHelper.CreateCallInfo(argumentInfo, 1)) { CallingContext = callingContext; _argumentInfo = BinderHelper.ToList(argumentInfo); _binder = RuntimeBinder.GetInstance(); } public override DynamicMetaObject FallbackGetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion) { return BinderHelper.Bind(this, _binder, BinderHelper.Cons(target, indexes), _argumentInfo, errorSuggestion); } } }