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

CSharpInvokeMemberBinder

using Microsoft.CSharp.RuntimeBinder.Semantics; using System; using System.Collections.Generic; using System.Dynamic; using System.Numerics.Hashing; namespace Microsoft.CSharp.RuntimeBinder { internal sealed class CSharpInvokeMemberBinder : InvokeMemberBinder, ICSharpInvokeOrInvokeMemberBinder, ICSharpBinder { private readonly CSharpArgumentInfo[] _argumentInfo; private readonly RuntimeBinder _binder; public BindingFlag BindingFlags => (BindingFlag)0; public bool IsBinderThatCanHaveRefReceiver => true; bool ICSharpInvokeOrInvokeMemberBinder.StaticCall { get { return _argumentInfo[0]?.IsStaticType ?? false; } } public CSharpCallFlags Flags { get; } public Type CallingContext { get; } public Type[] TypeArguments { get; } bool ICSharpInvokeOrInvokeMemberBinder.ResultDiscarded { get { return (Flags & CSharpCallFlags.ResultDiscarded) != CSharpCallFlags.None; } } public Expr DispatchPayload(RuntimeBinder runtimeBinder, ArgumentObject[] arguments, LocalVariableSymbol[] locals) { return runtimeBinder.DispatchPayload(this, arguments, locals); } public void PopulateSymbolTableWithName(Type callingType, ArgumentObject[] arguments) { RuntimeBinder.PopulateSymbolTableWithPayloadInformation(this, callingType, arguments); } public CSharpArgumentInfo GetArgumentInfo(int index) { return _argumentInfo[index]; } public CSharpArgumentInfo[] ArgumentInfoArray() { CSharpArgumentInfo[] array = new CSharpArgumentInfo[_argumentInfo.Length]; _argumentInfo.CopyTo(array, 0); return array; } public CSharpInvokeMemberBinder(CSharpCallFlags flags, string name, Type callingContext, IEnumerable<Type> typeArguments, IEnumerable<CSharpArgumentInfo> argumentInfo) : base(name, false, BinderHelper.CreateCallInfo(ref argumentInfo, 1)) { Flags = flags; CallingContext = callingContext; TypeArguments = BinderHelper.ToArray(typeArguments); _argumentInfo = BinderHelper.ToArray(argumentInfo); _binder = new RuntimeBinder(callingContext, false); } public int GetGetBinderEquivalenceHash() { int h = CallingContext?.GetHashCode() ?? 0; h = HashHelpers.Combine(h, (int)Flags); h = HashHelpers.Combine(h, base.Name.GetHashCode()); return BinderHelper.AddArgHashes(h, TypeArguments, _argumentInfo); } public bool IsEquivalentTo(ICSharpBinder other) { CSharpInvokeMemberBinder cSharpInvokeMemberBinder = other as CSharpInvokeMemberBinder; if (cSharpInvokeMemberBinder == null) return false; if (Flags != cSharpInvokeMemberBinder.Flags || CallingContext != cSharpInvokeMemberBinder.CallingContext || base.Name != cSharpInvokeMemberBinder.Name || TypeArguments.Length != cSharpInvokeMemberBinder.TypeArguments.Length || _argumentInfo.Length != cSharpInvokeMemberBinder._argumentInfo.Length) return false; return BinderHelper.CompareArgInfos(TypeArguments, cSharpInvokeMemberBinder.TypeArguments, _argumentInfo, cSharpInvokeMemberBinder._argumentInfo); } public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { BinderHelper.ValidateBindArgument(target, "target"); BinderHelper.ValidateBindArgument(args, "args"); return BinderHelper.Bind(this, _binder, BinderHelper.Cons(target, args), _argumentInfo, errorSuggestion); } public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { CSharpInvokeBinder cSharpInvokeBinder = new CSharpInvokeBinder(Flags, CallingContext, _argumentInfo).TryGetExisting(); return cSharpInvokeBinder.Defer(target, args); } string get_Name() { return base.Name; } string ICSharpBinder.get_Name() { return this.get_Name(); } } }