Help me pick a Dependency Injection framework for .Net

Possible Duplicate:
Which C#/.NET Dependency Injection frameworks are worth looking into?

Yes I know this question has been asked many times, but the various frameworks keep evolving, so I would like a fresh answer on the subject.

A few thoughts about the framework, they are not necessary black or white, but rather my preferences.

Things I like:

  • Convention based registrations
  • Constructor injection
  • Can also target Silverlight
  • Small footprint
  • One assembly
  • Fast
  • Thing I don't like:

  • Xml
  • Custom attributes
  • Service locator pattern
  • Things I don't think about:

  • Linq
  • Opensource

  • Sounds like you might want to try NInject.

    It has a definite focus on being easy to use with little configuration overhead (no bulky XML config files, etc). It even comes with a nice, shiny, fluent interface to make things understandable.


    autofac

    Ninject


    When you're not familiar yet with any of the big DI frameworks, you might consider the very easy SimpleServiceLocator (shameless plug). Let's compare it to your check list:

  • Constructor injection, check!
  • Can also target Silverlight, check!
  • Small footprint, check!
  • One assembly, nope 2. It needs the Common Service Locator.
  • Fast, double check!
  • No Xml, check! Only code based configuration is supported.
  • No Custom attributes, check! It is completely attribute free.
  • No Service locator pattern, check. Despite its name, you can do DI with it (just look at the examples on the site).
  • Open source, check! MIT License.
  • The idea behind the Simple Service Locator is:

    to provide .NET application developers with a inversion of control (IoC) framework that is truly easy to use, while allowing developers to replace it with a more feature-rich IoC framework when needed.

    The Simple Service Locator is an implementation of the Common Service Locator library. The Common Service Locator is a shared interface for inversion of control and dependency injection which application and framework developers can reference.

    链接地址: http://www.djcxy.com/p/82116.html

    上一篇: 为什么.NET委托不能被声明为静态?

    下一篇: 帮助我为.Net选择一个依赖注入框架