• Dependency Injection Frameworks


    Inversion of control, or IoC, is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming. Dependency injection is the main method to implement Inversion of Control.

    Manually injected dependency
    Framework-managed dependency

    There are several frameworks available to further automate this process, allowing a complete delegation of instantiation and marshalling of such dependencies to a "meta-factory", often called a Container or Injector.

    Dependency injection is a prime technique for building loosely coupled applications. It provides ways to handle the dependencies between objects.

    一、Unity

    The Unity Application Block (Unity) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection.

    二、Autofac

    Autofac is a fresh approach to IoC in .NET that utilises modern C#.

    Autofac was designed with modern .NET features and obsessive object-orientation in mind. It will change the way you approach dependency injection in .NET.

    三、Ninject

    lightning-fast dependency injection for .net

    Ninject helps you use the technique of dependency injection to break your applications into loosely-coupled, highly-cohesive components, and then glue them back together in a flexible manner.

    四、Managed Extensibility Framework

    The Managed Extensiblility Framework (MEF) is a new library in .NET that enables greater reuse of applications and components. Using MEF, .NET application can make the shift from being statically compiled to dynamically composed. If you are building extensible applications, extensible frameworks and application extensions, then MEF is for you.

    The MEF simplifies the creation of extensible applications. MEF offers discovery and composition capabilities that you can leverage to load application extensions.

    五、Castle MicroKernel/Windsor

    Castle Project offers two Inversion of Control Containers. The MicroKernel and the Windsor Container. Their documentation are kept together as the Windsor Container just augments the MicroKernel functionality.

    The Castle MicroKernel is an inversion of control container that was designed towards extensibility.

    Castle Windsor aggregates the MicroKernel and exposes a powerful configuration support. It is suitable for common enterprise application needs. It is able to register facilities and components based on the configuration and adds support for interceptors.

    六、Hiro

    Hiro is an IOC container compiler (currently in development) that will support the following features:

    Blazingly fast,Statically precompiled,Tiny,Supports Constructor and Property Injection

    七、LinFu

    The LinFu Framework is a set of libraries that extend the CLR by adding the following language features:

    Aspect-Oriented Programming,Dynamic Proxies,Late Binding,Mixins,Universal Event Handling,Closures with Lambda Arguments,Duck Typing,Design by Contract

    八、Funq

    This project provides a high performance DI framework by eliminating all runtime reflection through the use of lambdas and generic functions as factories.
    Developed entirely in C# using TDD, it's a container you can crack open and actually understand to the core.

    九、StructureMap

    StructureMap is a Dependency Injection / Inversion of Control tool for .Net that can be used to improve the architectural qualities of an object oriented system by reducing the mechanical costs of good design techniques. StructureMap can enable looser coupling between classes and their dependencies, improve the testability of a class structure, and provide generic flexibility mechanisms. Used judiciously, StructureMap can greatly enhance the opportunities for code reuse by minimizing direct coupling between classes and configuration mechanisms.

    Comments

    These information of the foregoing IoC frameworks are sorted out from the internet. In the following months, I plan to work on a serial posts about forementioned IoC containers to illustrate their usages.

    References

    1. Dependency injection - Wikipedia, the free encyclopedia
    2. PicoContainer - What is PicoContainer?
  • 相关阅读:
    [Qt]《开发指南》3.1源码分析
    [c++] 头文件
    [Qt] 信号和槽
    [Qt] 编译问题
    [Qt] 项处理组件
    MYSQL 之 JDBC(十三):处理事务
    MYSQL 之 JDBC(十二): 处理Blob
    MYSQL 之 JDBC(十一): JDBC获取插入记录的主键值
    MYSQL 之 JDBC(十): JDBC的元数据
    MYSQL 之 JDBC(九):增删改查(七)DAO的补充和重构
  • 原文地址:https://www.cnblogs.com/huyh/p/1758509.html
Copyright © 2020-2023  润新知