Ejemplo n.º 1
0
        static unsafe List <A> CastBasAIL(List <B> bIn)
        {
            DynamicMethod dynamicMethod = new DynamicMethod("foo1", typeof(List <A>), new[] { typeof(List <B>) }, typeof(void));
            ILGenerator   il            = dynamicMethod.GetILGenerator();

            il.Emit(OpCodes.Ldarg_0);                   // copy first argument  to stack
            il.Emit(OpCodes.Ret);                       // return the item on the stack
            CCastDelegate HopeThisWorks = (CCastDelegate)dynamicMethod.CreateDelegate(typeof(CCastDelegate));

            return(HopeThisWorks(bIn));
        }
Ejemplo n.º 2
0
        static unsafe List <A> CastBasAIL(List <B> bIn)
        {
            // this was attempt #2.  Somewhere along the line, I got it into my head that this
            // did not work.  However, when I came back to demonstrate that it didnt work, it now does.

            DynamicMethod dynamicMethod = new DynamicMethod("foo1", typeof(List <A>), new[] { typeof(List <B>) }, typeof(void));
            ILGenerator   il            = dynamicMethod.GetILGenerator();

            il.Emit(OpCodes.Ldarg_0);                   // copy first argument  to stack
            il.Emit(OpCodes.Ret);                       // return the item on the stack
            CCastDelegate HopeThisWorks = (CCastDelegate)dynamicMethod.CreateDelegate(typeof(CCastDelegate));

            return(HopeThisWorks(bIn));
        }