Beispiel #1
0
        public static ILGenerator ld_method_info(this ILGenerator il, MethodBase methodBase)
        {
            if (methodBase == null) throw new ArgumentNullException("methodBase");

            // todo. use hackarounds (see the Hackarounds namespace nearby)!
            il.Emit(OpCodes.Ldtoken, methodBase.AssertCast<MethodInfo>());
            il.Emit(OpCodes.Ldtoken, methodBase.DeclaringType);
            il.EmitCall(OpCodes.Call, typeof(MethodBase).GetMethod("GetMethodFromHandle", new[] { typeof(RuntimeMethodHandle), typeof(RuntimeTypeHandle) }), null);

            return il;
        }
Beispiel #2
0
        public static ILGenerator newobj(this ILGenerator il, MethodBase ctor)
        {
            if (ctor == null) throw new ArgumentNullException("ctor");

            // todo. use hackarounds (see the Hackarounds namespace nearby)!
            il.Emit(OpCodes.Newobj, ctor.AssertCast<ConstructorInfo>());
            return il;
        }
Beispiel #3
0
        public static ILGenerator ldtoken(this ILGenerator il, MethodBase methodBase)
        {
            if (methodBase == null) throw new ArgumentNullException("methodBase");

            // todo. use hackarounds (see the Hackarounds namespace nearby)!
            il.Emit(OpCodes.Ldtoken, methodBase.AssertCast<MethodInfo>());
            return il;
        }
Beispiel #4
0
 public static ILGenerator ldftn(this ILGenerator il, MethodBase mb)
 {
     il.Emit(OpCodes.Ldftn, mb.AssertCast<MethodInfo>());
     return il;
 }