Exemplo n.º 1
0
        public sealed override Delegate CreateDelegate(RuntimeTypeHandle delegateType, object target, bool isStatic, bool isVirtual, bool isOpen)
        {
            if (isOpen)
            {
                MethodInfo methodInfo = (MethodInfo)MethodInvokeInfo.Method;

                short resolveType = OpenMethodResolver.OpenNonVirtualResolve;

                if (methodInfo.DeclaringType.IsValueType && !methodInfo.IsStatic)
                {
                    // Open instance method for valuetype
                    resolveType = OpenMethodResolver.OpenNonVirtualResolveLookthruUnboxing;
                }

                return(RuntimeAugments.CreateDelegate(
                           delegateType,
                           new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, default(GCHandle), 0, resolveType).ToIntPtr(),
                           target,
                           isStatic: isStatic,
                           isOpen: isOpen));
            }
            else
            {
                return(base.CreateDelegate(delegateType, target, isStatic, isVirtual, isOpen));
            }
        }
Exemplo n.º 2
0
 public static Delegate UnsafeDelegateFromStaticMethodFunctionPointer(System.Type delegateType, IntPtr pfnStaticManagedMethod)
 {
     return(RuntimeAugments.CreateDelegate(
                delegateType.TypeHandle,
                pfnStaticManagedMethod,
                thisObject: null, isStatic: true, isOpen: true));
 }
Exemplo n.º 3
0
 public override Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen)
 {
     return(RuntimeAugments.CreateDelegate(
                delegateType,
                MethodInvokeInfo.LdFtnResult,
                target,
                isStatic: isStatic,
                isOpen: isOpen));
 }
Exemplo n.º 4
0
 public sealed override Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen)
 {
     if (isOpen)
     {
         return(RuntimeAugments.CreateDelegate(
                    delegateType,
                    new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, 0).ToIntPtr(),
                    target,
                    isStatic: isStatic,
                    isOpen: isOpen));
     }
     else
     {
         return(base.CreateDelegate(delegateType, target, isStatic, isVirtual, isOpen));
     }
 }
Exemplo n.º 5
0
 public sealed override Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen)
 {
     if (!isOpen)
     {
         // We're creating a delegate to a virtual override of this method, so resolve the virtual now.
         IntPtr resolvedVirtual = OpenMethodResolver.ResolveMethod(MethodInvokeInfo.VirtualResolveData, target);
         return(RuntimeAugments.CreateDelegate(
                    delegateType,
                    resolvedVirtual,
                    target,
                    isStatic: false,
                    isOpen: isOpen));
     }
     else
     {
         // Create an open virtual method by providing the virtual resolver to the delegate type.
         return(RuntimeAugments.CreateDelegate(
                    delegateType,
                    MethodInvokeInfo.VirtualResolveData,
                    target,
                    isStatic: false,
                    isOpen: isOpen));
     }
 }