开发者

Help me pick a Dependency Injection framework for .Net [duplicate]

This question already has answers here: 开发者_如何学C Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜