IOC is a pattern which decouples the use of an interface from the concrete implementation of that interface. By eliminating this coupling:
- The code can be tested by using special test implementations of the interface.
- Fewer DLLs need to be deployed on each tier of a multi-tiered deployment.
- Project compilation may be sped up as there are fewer project dependencies.
- Alternate implementations of the interface can be configured for use without requiring changes to the main application code. This could mean changing from MSSQL to Oracle with a simple configuration file change.
An IOC Container is a pattern which allows the application to create an instance of the interface without knowing the specific concrete class that will be used.
Munq is a very small, fast dependency injection container designed for ASP.NET applications, both Webforms and MVC. It has, by design, limited features. The main goal has been to minimize the CPU required for Resolving types from the container.
- Speed. High volume websites need to minimize the amount of work each page request needs to execute. Even 1/10th of a second can make a difference of a user’s perception of the site.
- Simplicity. Munq does one thing but does it well. It resolves requests for instances of Types by executing Factories that have been previously registered in the container.
- Provide Web Lifetime Management. Windows applications can get by with a container that has the option of creating a new instance each request or re-use the same instance. In the web application world, objects can have lifetimes that only span the current Request, the user’s Session, or be Cached reduce database load and access delays.
Here below is the output by testing in the web application which implemented the IWebService interface and all Containers were configured to return new instances for all interfaces which were a shared instance. Running 10000 iterations for each use case had the following results.
Munq DI IOC Container is the smallest, fastest IOC container that I know of. It is faster than any of the big players, Unity, Windsor Castle, Ninject, StructureMap, etc.
You can download it from package manager:
PM> Install-Package Munq.IocContainer
Also, you can download it from the visual studio:
For more details:
About Munq and download
Using Munq IOC Container Version 3 in ASP.NET MVC 3