Using Unity to implement AOP

Source: Internet
Author: User
Tags aop

Premise

Refer to the following file

Microsoft.Practices.ObjectBuilder2.dll

Microsoft.Practices.Unity.dll

Microsoft.Practices.Unity.Configuration.dll

Microsoft.Practices.Unity.Interception.dll

Microsoft.Practices.Unity.Interception.Configuration.dll

Microsoft.Practices.Unity.StaticFactory.dll

can download from website http://unity.codeplex.com/

The implementation class in this article inherits from the Ioutput interface

1: public interface IOutput {
2:   void Output(int  x);
3: }

Implementation effect

I have two methods to output strings, call Ioutput implementation classes to output, such as:

1: class OutputImplement2 : IOutput {
2:   public void  Output(int x) {
3:     Console.WriteLine("output:{0}", x);
4:    }
5: }

Call it in the main function

1: var op2=new OutputImplement2();
2: op2.Output(22);

, and the role of AOP is to op2 through other code. The final result of an output method being injected into another execution before or after execution may be:

Here in addition to the arrow refers to a sentence outside the other is injected into this method.

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.