AOP Application Sample program in Unity container

Source: Internet
Author: User
Tags aop microsoft website

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.