-
Notifications
You must be signed in to change notification settings - Fork 530
Changes in Ninject 2
nkohari edited this page Sep 13, 2010
·
15 revisions
Ninject 2 represents a ground-up rewrite of the original Ninject, created to take advantage of new language features and re-dedicate the project to obsessive minimization and simplicity.
- Cache-and-collect lifecycle management: Rather than using binding behaviors, Ninject 2 uses a scoping system and leverages the garbage collector to reclaim instances. (This is explained in detail below.)
-
Multi-injection: The kernel in Ninject 2 now has
GetAll<T>()
methods, and supports injection of multiple targets with typesIEnumerable<T>
,List<T>
, and arrays ofT
. - Constrained resolution: Rather than just declaring conditional bindings, constraining predicates can now flow into a resolution request from the point of injection.
- Common Service Locator support: Because of multi-injection, Ninject 2 now has full support for the Common Service Locator.
- Optional modules: You can now register bindings directly on the kernel; modules are optional. If you register bindings in a module, and then unload the module, the bindings will be un-registered.
- Automatic module scanning: Ninject 2 can scan directories for assemblies that contain modules, and load them into the kernel.
- Simplified extension model: Internally, Ninject 2 relies on an inversion of control container of its own, reducing factory bloat and making extension of the core much simpler.
- Mono support: Ninject 2 finally has proper support for the Mono project’s version of the CLR.
- Support for .NET 2.0: Since Ninject 2 relies on LINQ, .NET 2.0 support is now no longer possible.
- Field injection: This is a bad practice, and has been cut for minimization.
-
Behavior attributes: Since behaviors have been cut and replaced by the new cache-and-collect system, attributes like
[Singleton]
no longer make sense.
Some things have been moved from the core to extensions as well, including aspect-oriented programming support (interception) and logging.
Licensed under Apache 2 License
Contents
- Home
- Why Use Ninject
- Getting Started
- Dependency Injection By Hand
- Dependency Injection With Ninject
- Injection Patterns
- Multi Injection
- Object Scopes
- Modules and the Kernel
- Providers, Factory Methods and the Activation Context
- The Activation Process
- How Injection Works
- Contextual Binding
- Conventions-Based Binding