Esempio n. 1
0
        protected virtual object?DynamicInvokeImpl(object?[]?args)
        {
            if (IsDynamicDelegate())
            {
                // DynamicDelegate case
                object?result = ((Func <object?[]?, object?>)m_helperObject)(args);
                DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
                return(result);
            }
            else
            {
                DynamicInvokeInfo dynamicInvokeInfo = ReflectionAugments.ReflectionCoreCallbacks.GetDelegateDynamicInvokeInfo(GetType());

                object?result = dynamicInvokeInfo.Invoke(m_firstParameter, m_functionPointer,
                                                         args, binderBundle: null, wrapInTargetInvocationException: true);
                DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
                return(result);
            }
        }
        public sealed override DynamicInvokeInfo GetDelegateDynamicInvokeInfo(Type type)
        {
            RuntimeTypeInfo runtimeType = type.CastToRuntimeTypeInfo();

            DynamicInvokeInfo?info = runtimeType.GenericCache as DynamicInvokeInfo;

            if (info != null)
            {
                return(info);
            }

            RuntimeMethodInfo invokeMethod = runtimeType.GetInvokeMethod();

            MethodInvoker methodInvoker = invokeMethod.MethodInvoker;
            IntPtr        invokeThunk   = ReflectionCoreExecution.ExecutionDomain.ExecutionEnvironment.GetDynamicInvokeThunk(methodInvoker);

            info = new DynamicInvokeInfo(invokeMethod, invokeThunk);
            runtimeType.GenericCache = info;
            return(info);
        }