Ninject - Open Source Dependency Injector for .Net

Ninject is a lightweight dependency injection framework for .NET applications. It is one of the several Inversion od Control(loc) containers available for .Net. It helps us to split our application into a collection of loosely-coupled,highly cohesive pieces and then glue them back together in a flexible manner. It makes our code easier to write, reuse, test and modify.

Why use Ninject

It uses a fluent interface to declare type bindings whereas the other frameworks rely on XML configuration files. It is a lightweight framework and aims to keep things simple and straightforward. It uses an extremely flexible form of binding called contextual binding.

How Ninject works

  • Ninject uses a central object to provide concrete implementations of dependencies at runtime.

  • Repeating calls via reflection as in dependency injection by hand can be very slow.Ninject takes advantage of the light weight code generation system firstintroduce in version 2.0 of the CLR.

  • By default, the Standard Kernel will create dynamic methods that can be used to inject values into the different injection targets. These dynamic methods are then triggered via delegate calls

Ninject Setup

Ninject is a pre-built dll which is available for download from github and have to reference Ninject.dll in your project.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: