private static void TestAopWrapper() { ISimpleService svc = AOPFactory.CreateInstance <OtherService, ISimpleService>(1); svc.Execute(); var rst = svc.GetResult(); Console.WriteLine("执行结果为:" + rst); AOPFactory.Save(); }
static void Main(string[] args) { var test = AOPFactory.CreateInstance <Test, ITest>(); var test2 = AOPFactory.CreateInstance <Test>(); var t = test.GetAll <int>(null); Console.WriteLine(t.Result); test.Write(); int i = 5; test.Write(i); Console.WriteLine(i); string s = "1"; test.Write(ref s); Console.WriteLine(s); test.Write2(out s); Console.WriteLine(s); test.Write(out i); Console.WriteLine(i); test.Write2222(out i); Console.WriteLine(i); object o = false; test.Write(out o); Console.WriteLine(o); var userSvc = AOPFactory.CreateInstance <UserService, IUserService>(new RepositoryContext(), new Repository <User>()); var flag = userSvc.Delete(Guid.NewGuid()); var model = userSvc.GetAll(); var a = userSvc.Add(new UserModel()); var b = userSvc.Get(); var c = userSvc.GetByID(Guid.NewGuid()); var d = userSvc.GetOne(); var e = userSvc.GetPage(1, 10); var f = userSvc.Update(new UserModel()); Console.WriteLine(model.Result); Console.WriteLine(e.Result); AOPFactory.Save(); Console.Read(); }
static void Main(string[] args) { AOPFactory factory = new AOPFactory(); Stopwatch sw = new Stopwatch(); Console.WriteLine("AOP 测试开始..."); sw.Start(); int allCount = 35000; for (int i = 0; i < allCount; i++) { BizObject obj = new BizObject(); int result = obj.GetValue(); } sw.Stop(); Console.WriteLine("New Object 测试,执行{0}次耗时{1} ms", allCount, sw.Elapsed.TotalMilliseconds); Console.WriteLine("New Object 测试,平均每次耗时{0} ms", sw.Elapsed.TotalMilliseconds / allCount); sw.Reset(); sw.Start(); for (int i = 0; i < allCount; i++) { IBizObject obj = factory.Create <IBizObject>(new BizObject()); int result = obj.GetValue(); } sw.Stop(); Console.WriteLine("AOP 测试,执行{0}次耗时{1} ms", allCount, sw.Elapsed.TotalMilliseconds); Console.WriteLine("AOP 测试,平均每次耗时{0} ms", sw.Elapsed.TotalMilliseconds / allCount); sw.Reset(); sw.Start(); for (int i = 0; i < allCount; i++) { IBizObject obj = factory.Create <IBizObject>(); int result = obj.GetValue(); } sw.Stop(); Console.WriteLine("AOP+IOC 测试,执行{0}次耗时{1} ms", allCount, sw.Elapsed.TotalMilliseconds); Console.WriteLine("AOP+IOC 测试,平均每次耗时{0} ms", sw.Elapsed.TotalMilliseconds / allCount); Console.Read(); }