Esempio n. 1
0
        private static void EmitNewDelegate(TracingILGenerator il, Type targetType, MethodInfo method, Action <TracingILGenerator> loadTargetEmitting, Type delegateType)
        {
            loadTargetEmitting(il);
            if (targetType.IsValueType)
            {
                il.EmitBox(targetType);
            }

            if (method.IsStatic || method.IsFinal || !method.IsVirtual)
            {
                il.EmitLdftn(method);
            }
            else
            {
                il.EmitDup();
                il.EmitLdvirtftn(method);
            }

            il.EmitNewobj(delegateType.GetConstructor(_delegateConstructorParameterTypes));
        }