.Net Common IOC framework and AOP framework

IOC framework

  1. Unity : Microsoft patterns & practicest team developed the IOC dependency injection framework that supports AOP crosscutting concerns.
  2. MEF (Managed Extensibility Framework): an extensible framework for .NET applications, plug-in system can be developed.
  3. The Spring.NET : dependency injection, aspect-oriented programming (the AOP), abstract data access ,, and ASP.NET integration.
  4. Autofac : The most popular IOC and dependency injection frame, lightweight and high performance of the project code is almost no invasive.
  5. Ninject : IOC injected lightweight framework based on open source .NET dependency

AOP framework

  1. Castle
  2. Encase  is written in C # AOP framework developed for the .NET platform. Encase provides the unique aspects (Aspects) deployed to the runtime code, while another AOP framework profile dependent manner. This deployment (aspects) of ways to help less experienced developers to improve development efficiency.
  3. NKalore  is a programming language that extends C # .net platform allows the use of AOP in. NKalore syntax is simple, intuitive, its compiler is based on Mono C # compiler (MCS). NKalore currently only on the command line or inside #Develop use. NKalore compatible with the Common Language Specification CLS (Common Language Specification), which can be used in any .NET development environments, including Microsoft Visual Studio .NET.
  4. PostSharp  read byte .NET module, is converted into an object model. Let plug-in model analysis and conversion and written back to MSIL. PostSharp the development process analytics applications as easy as analysis code rules and design patterns, it makes the idea of change for the program development aspect-oriented software development (AOSD / AOD) thought.
  5. AspectDNG  goal is to provide a simple and powerful AOP-GAOP implemented as a .NET developer. It emulate AspectJ Java under open source tools and Spoon, maturity is also very close to them.
  6. RAIL (the Instrumentation Assembly Runtime Library) open source project can be treated and controlled adjustment rebuild before C # assemblies to load and run. In C # CLR, we have the ability to dynamically load the assembly and get the classes and methods of assembly, RAIL (Runtime Assembly Instrumentation Library) appeared to fill some gaps in the CLR process.
  7. SetPoint is fully functional (full-featured) AOP engine under a .NET framework. It is called a semantic focus point of tangency (semantic pointcuts) is defined dependent on the use of RDF / OWL of which is a function of IL-level, highly dynamic weaver & LENDL, a compelling definition language ,,,,,,
  8. DotNetAOP provide AOP framework for the basic properties of CLR language.
  9. NAop is a DotNet under AOP framework.
  10. AspectSharp is free AOP framework under DotNet, it Dynamic Proxies and XML as a configuration file.

Realization of a Castle

// first download Castle.Windsor.dll
 // custom Interceptor 
public  class myInterceptor: IInterceptor   
{   
    public  void Intercept (IInvocation Invocation)   
    {   
        PreProceed (Invocation);   
        invocation.Proceed ();   
        PostProceed (Invocation);   
    }   
    public  void PreProceed (IInvocation Invocation)   
    {   
        Console.WriteLine ( " before execution method " );   
    }   

    public  void PostProceed (IInvocation Invocation)   
    {   
        Console.WriteLine ( "After performing the method " );   
    }   
}   

// user registration interface and implement 
public  interface IUserProcessor   
{   
    void RegUser (the User User);   
}   

public  class UserProcessor: IUserProcessor   
{   
    public  Virtual  void RegUser (the User User)   
    {   
        Console.WriteLine ( " registered user .name: {0}, PassWord: {}. 1 " , user.name, user.password);   
    }   
}   

// client calls 
public  class client   
{   
    public  static  void Run()  
    {  
        try  
        {  
            ProxyGenerator generator = new ProxyGenerator();  
            MyInterceptor interceptor = new MyInterceptor();  
            UserProcessor userprocessor = generator.CreateClassProxy<UserProcessor>(interceptor);  
            User user= new User() { Name = "lee", PassWord = "123123123123" };  
            userprocessor.RegUser(user);  
        }  
        catch (Exception ex)  
        {  
            throw ex;  
        }  
    }  
}  

 

Guess you like

Origin www.cnblogs.com/zhaoshujie/p/12080569.html