public DynamicInstructionN(Type delegateType, CallSite site) { var methodInfo = delegateType.GetMethod("Invoke"); var parameters = methodInfo.GetParameters(); _target = CallInstruction.Create(methodInfo, parameters); _site = site; _argumentCount = parameters.Length - 1; _targetDelegate = site.GetType().GetField("Target").GetValue(site); }
public DynamicInstructionN(Type delegateType, CallSite site) { var methodInfo = delegateType.GetMethod("Invoke"); var parameters = methodInfo.GetParameters(); // <Delegate>.Invoke is ok to target by a delegate in partial trust (SecurityException is not thrown): _targetInvocationInstruction = CallInstruction.Create(methodInfo, parameters); _site = site; _argumentCount = parameters.Length - 1; _targetDelegate = site.GetType().GetInheritedFields("Target").First().GetValue(site); }
public void EmitCall(MethodInfo method, ParameterInfo[] parameters) { Emit(CallInstruction.Create(method, parameters)); }