Home / Posts tagged "IoC"

Ninject.Extensions.Factory introduction

The new release of Ninject 3.0 comes with a new extension that adds support for factories to Ninject. It supports factory interfaces, Func and Lazy. In this blog post I will explain how they are used.

Why using factories?
The recommended way to use IoC containers is that the composition root of the application is the only place where the container is accessed. Unfortunately many application can’t create everything at once during the application start or at the beginning of a web/wcf request because not everything is known at this moment. Therefore these applications need a way to create new instances using the kernel at a later point. Preferably we want to do this without introducing a reference to the container. This is where factories come into play. Instead of injecting the kernel into classes that need to create new instances we inject a factory. This factory is responsible to create the new instances using the kernel. There are two ways to implement such a factory: A factory interface and as a Func or Lazy.
Continue reading

How to use the additional Ninject Scopes of NamedScope

The Named Scope extension adds the three additional Scopes InCallScope, InNamedScope and InParentScope to Ninject. In this Blogpost I want to explain how they are used. Some parts of this post expect that you have a basic knowledge about the Context Preservation extension. Consider reading my blog post about the Context Preservation Extension before reading this one.

Continue reading

Official Ninject MVC extension gets support for MVC3

MVC3 added support for Dependency Injection frameworks. To take advantage of these features I did a completely new implementation of the Ninject.Web.Mvc extension. Unlike other existing MVC3 implementations for Ninject, this extension goes further than just adding a IDependencyResolver for Ninject. It has tightly Ninject integrated support for various things such as Filters and Validators.

This post assumes that you have a basic knowledge about MVC, Ninject and Dependency Injection in general.

Continue reading