Agnostic IoC is an open source wrapper API to allow you to write your code without knowing the final container, it simply translates between the Agnostic API and the original Dependency Injection Framework. It is similar in overall goal to vNext Dependency Injection from Microsoft.

At it’s core, the original design purpose was to allow developers of shippable modules to be able to use dependency injection principles without shipping with a specific container implementation, the use cases are seemingly much greater than this.

Agnostic at it’s core is designed NOT to replace the original Dependency Injection Container functionality, as such – it does not interfere if the original Container supports Property Injection, Webforms, MVC or whatever, you still have the freedom to pick your IoC container based on it’s feature set / performance or whatever other criteria matter to you.

How does it work?
At the crux, you build your code against the Agnostic.Core API (installed using a nuget package), this allows you to define dependency registrations, resolve dependencies etc etc. In the consuming code, you simply add the nuget packages related to the final container which performs the translations.

e.g. I write my module installing ONLY Agnostic.IoC.Core and when I use it I reference Agnostic.IoC.Core & Agnostic.IoC.StructureMap.

Key Features

  • Wide variety of frameworks supported (see supported frameworks)
  • Use and manipulate an existing container from the original dependency injection framework
  • Simple adapter implementation to add support for your own frameworks
  • Can be used anywhere you would use any other DI framework
  • Self discovery and initialisation of adapters (switchable)

How does this differ from the vNext Dependency Injection?
At it’s core Agnostic IoC and vNext Dependency injection solve a very similar problem. At the time of writing, vNext’s Dependency Injection registration API is not complete, vNext’s Dependency Injection API currently also has a limitation of only resolving a single constructor parameter and vNext.

Unlike vNext Dependency Injection, Agnostic IoC DOES NOT ship with a container out of the box, we don’t see a need to and it’s not the purpose of the library.

Unlike vNext Dependency Injection, Agnostic also has no implementation to directly support MVC as it is the view of the Agnostic developers that this is the responsibility of the original vendor. Nearly (if not) all of the DI Containers Agnostic deals with support MVC in their own way. It may well be that someone writes a hook into the vNext Dependency Injection API in the near future.

Related Articles

Please also feel free to investigate the dedicated documentation pages at the top of this site.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s