Ejemplo n.º 1
0
        public void LCGDoubleCallFuncNoArgInt32()
        {
            Func <Object, Int32> func = ExpressionTreeReflection.ReflectFunction <Int32>(suType, "AMethod");

            func = LCGReflection.ReflectFunction <Int32>(suType, "AMethod");
            Assert.That(func(suInstance), Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public void TestPerformanceGain()
        {
            Func <Object, Int32> func    = ExpressionTreeReflection.ReflectFunction <Int32>(suType, "AMethod");
            Func <Object, Int32> lcgfunc = LCGReflection.ReflectFunction <Int32>(suType, "AMethod");
            MethodInfo           minfo   = suType.GetMethod("AMethod", BindingFlags.Public | BindingFlags.Instance);
            Double RefDuration           = With.PerformanceCounter(() => { for (Int32 I = 0; I < 1000000; ++I)
                                                                           {
                                                                               minfo.Invoke(suInstance, new Object[] { });
                                                                           }
                                                                   });
            Double ExpDuration = With.PerformanceCounter(() => { for (Int32 I = 0; I < 1000000; ++I)
                                                                 {
                                                                     func(suInstance);
                                                                 }
                                                         });
            Double LcgDuration = With.PerformanceCounter(() => { for (Int32 I = 0; I < 1000000; ++I)
                                                                 {
                                                                     lcgfunc(suInstance);
                                                                 }
                                                         });

            Console.WriteLine("Reflection = {0} Expression Tree {1} LCG {2}", RefDuration, ExpDuration, LcgDuration);
        }
Ejemplo n.º 3
0
        public void LcgTestFuncOneArgInt32Overload()
        {
            Func <Object, String, Int32> func = LCGReflection.ReflectFunction <String, Int32>(suType, "BMethod");

            Assert.That(func(suInstance, "test0"), Is.EqualTo(5));
        }
Ejemplo n.º 4
0
        public void LcgTestFuncOneArgInt32()
        {
            Func <Object, Int32, Int32> func = LCGReflection.ReflectFunction <Int32, Int32>(suType, "BMethod");

            Assert.That(func(suInstance, 4), Is.EqualTo(8));
        }