Forwarding Please specify the source:https://www.cnblogs.com/zhiyong-ITNote/p/9127001.html
There is no description of the AOP application sample for the Unity container, and a tutorial was found on the Microsoft website (https://docs.microsoft.com/zh-cn/previous-versions/msp-n-p/dn507492 (v% 3dpandp.30) Look at the eye pain, and not very detailed. I made a demo myself based on some information. Key code:
///Unity Container AOP can do the functions of IOC, when we use AOP///The instantiation of the dependency is also completed. ///Complete diIunitycontainer container =NewUnityContainer (); container. Registertype<ifoorepository, foorepository>() . Registertype<ibarrepository, barrepository>(); ///Barserice's AOPContainer. Addnewextension<interception>() . Registertype<ifooservice, Fooservice> ()///Fooservice's AOP. Configure<interception>() . Setinterceptorfor<IFooService> (Newinterfaceinterceptor ());///Barserice's AOPContainer. Addnewextension<interception>() . Registertype<ibarservice, barserice>() . Configure<Interception>() . Setinterceptorfor<IBarService> (Newinterfaceinterceptor ());varInvoke = container. Resolve<iocinvoke>(); invoke. Run (); SW. Stop (); Console.WriteLine ("time spent: {0}", SW. Elapsed); Console.read ();
View Code
Code Link: https://pan.baidu.com/s/1QjAMpw55M5Czd3AslMEksw Password: dz2z
Forwarding Please specify the source:https://www.cnblogs.com/zhiyong-ITNote/p/9127001.html
AOP Application Sample program in Unity container