Example #1
0
        public void TestReflectConstructors()
        {
            Func <Object> func = ExpressionTreeReflection.ReflectConstructor(suType);
            Object        su   = func();

            Assert.That(su, Is.InstanceOfType(typeof(SimpleUnknown)));
        }
Example #2
0
        public void TestPerformanceGainConstructors()
        {
            Func <Object>   func        = ExpressionTreeReflection.ReflectConstructor(suType);
            ConstructorInfo cinfo       = suType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { }, null);
            Double          RefDuration = With.PerformanceCounter(() => { for (Int32 I = 0; I < 100000; ++I)
                                                                          {
                                                                              cinfo.Invoke(new Object[] { });
                                                                          }
                                                                  });
            Double ExpDuration = With.PerformanceCounter(() => { for (Int32 I = 0; I < 100000; ++I)
                                                                 {
                                                                     func();
                                                                 }
                                                         });

            Console.WriteLine("Reflection = {0} Expression Tree {1}", RefDuration, ExpDuration);
        }