static void Main(string[] args) { int times = 2; DynamicMethodExecutor executor = new DynamicMethodExecutor(typeof(Program).GetMethod("Call")); Stopwatch watch3 = new Stopwatch(); watch3.Start(); for (int i = 0; i < times; i++) { executor.Execute(new Program(), new object[3] { "test", "", "" }); } watch3.Stop(); Console.WriteLine(watch3.Elapsed + " (Dynamic executor)"); ModelBinderFactory.Current.SetModelBinder(new DefaultModelBinder());//a way set selfdefined modelbinder,you can ignore it IConfigurationSource src = ConfigurationManager.GetSection("DataAccess") as IConfigurationSource; DriverBase db = DatabaseFactory.CreateDriver(src); //DataTable dt = db.GetDataTable("select employeeid,lastname,firstname from dbo.Employees"); //IEnumerable<Employee> list = db.FindAll<Employee>("select employeeid,lastname,firstname from dbo.Employees"); //int count = 0; //IEnumerable<Employee> list = db.PagerList<Employee>("select employeeid,lastname,firstname from dbo.Employees", 1, count, "employeeid"); System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); //int count; //IEnumerable<Blog> list = db.SetPageSize(1) // .PagerList<Blog>("select * from blog", 1,out count); // DataTable dt = db.GetDataTable("select * from blog"); IEnumerable <Blog> list = db.FindAll <Blog>("select * from blog"); timer.Stop(); Console.WriteLine("first timespan:" + timer.Elapsed); timer.Reset(); timer.Start(); list = db.FindAll <Blog>("select * from blog"); timer.Stop(); Console.WriteLine("second timespan:" + timer.Elapsed); // list = db.FindAll<Employee>("select employeeid,lastname,firstname from dbo.Employees"); //foreach (Employee model in DefaultModelBinder.BindModel<Employee>(dt)) //{ // Console.WriteLine(model.FirstName); //} //Console.WriteLine("Count:"+count); //foreach (Blog model in list) //{ // Console.WriteLine(model.Name); //} //foreach (DataRow dr in dt.Rows) //{ // foreach (DataColumn dc in dt.Columns) // { // Console.Write(dc.ColumnName + ":" + dr[dc.ColumnName] + "\t"); // } // Console.WriteLine(); //} //Console.WriteLine("Run 1 - configuration with xml file"); //using (WindsorContainer container = new WindsorContainer("castle.config")) //{ // container.AddFacility<LoggingFacility>(f => f.UseLog4Net()); // ISomething something = container.Resolve<ISomething>(); // something.DoSomething(""); // Console.WriteLine("Augment 10 returns " + something.Augment(10)); //} //Console.WriteLine("Run 2 - configuration fluent"); //using (WindsorContainer container = new WindsorContainer()) //{ // container.Register( // Component.For<IInterceptor>() // .ImplementedBy<BetterDumpInterceptor>() // .Named("myinterceptor")); // container.Register( // Component.For<ISomething>() // .ImplementedBy<Something>() // .Interceptors(InterceptorReference.ForKey("myinterceptor")).Anywhere); // ISomething something = container.Resolve<ISomething>(); // something.DoSomething(""); // Console.WriteLine("Augment 10 returns " + something.Augment(10)); //} //Console.WriteLine("Run 3 - configuration fluent"); //using (WindsorContainer container = new WindsorContainer()) //{ // Dictionary<Type, List<String>> RegexSelector = new Dictionary<Type, List<string>>(); // RegexSelector.Add(typeof(DumpInterceptor), new List<string>() { "DoSomething" }); // RegexSelector.Add(typeof(LogInterceptor), new List<string>() { "Augment" }); // InterceptorSelector selector = new InterceptorSelector(RegexSelector); // container.Register( // Component.For<IInterceptor>() // .ImplementedBy<DumpInterceptor>() // .Named("myinterceptor")); // container.Register( // Component.For<IInterceptor>() // .ImplementedBy<LogInterceptor>() // .Named("LogInterceptor")); // container.AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config")); // container.Register( // Component.For<ISomething>() // .ImplementedBy<Something>() // .Interceptors(InterceptorReference.ForKey("myinterceptor") , // InterceptorReference.ForKey("LogInterceptor") // ) // .SelectedWith(selector).Anywhere); // ISomething something = container.Resolve<ISomething>(); // something.DoSomething(""); // Console.WriteLine("Augment 10 returns " + something.Augment(10)); //} Console.ReadKey(); }