IoC.Configuration is a container agnostic configuration of dependency injection.

IoC.Configuration is a wrapper around popular IoC containers, with additional functionality (see below). Currently Ninject and Autofac are supported through the usage of Nuget extension packages IoC.Configuration.Ninject and IoC.Configuration.Autofac.

Among other things, it allows:
  • Specifying dependency injection configuration in XML configuration file, as well as in IoC.Configuration module classes, or third party IoC container modules (e.g., Autofac or Ninject modules).
  • Easy switching between containers to use for service resolution (e.g., Autofac, Ninject).

In addition, the configuration file has sections for settings, plugins, startup actions, dynamically generated implementations of interfaces (see Autogenerated Services), etc.

All these functionality will be explained in corresponding sections, however here is a quick overview:

  • The dependency injection bindings are done using any combination of the following techniques:

    • In IoC.Configuration module classes using chained methods, pretty similar to how it is done in popular containers, Ninject and Autofac.


      The IoC.Configuration module classes should either implement IoC.Configuration.DiContainer.IDiModule, or extend the class IoC.Configuration.DiContainer.ModuleAbstr, and override the method Load().

    • In module classes of one of popular IoC packages (such as Autofac or Ninject). These modules will be referred as native modules.

    • In XML configuration file. This method is the preferred way to configure the dependency injection, since it is the most flexible. XML configuration files have sections for type bindings, as well as sections for IoC.Configuration or native (i.e., Autofac, Ninject, etc) modules.


    IoC.Configuration has its own syntax for type bindings, which reminds the syntax used in Ninject. However, IoC.Configuration translates these type bindings into 3-rd party IoC container (e.g., Autofac, Ninject, etc) bindings .

  • Type resolutions are done using one of popular IoC containers (e.g., Autofac, Ninject, etc), through the usage of implementations of IoC.Configuration.DiContainer.IDiManager interface.


    Currently, two implementations of IoC.Configuration.DiContainer.IDiManager are availabe, Ninject and Autofac implementations). These implementations are in packages IoC.Configuration.Ninject and IoC.Configuration.Autofac.

  • The container (e.g., Autofac, Ninject) used by IoC.Configuration can be switched in XML configuration file. Here is an exert from IoCConfiguration_Overview.xml, that shows the usage of element diManagers to specify container for resolving types:

The value of type attribute should be a type that implements
<diManagers activeDiManagerName="Autofac">
    <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
        Use parameters element to specify constructor parameters,
        if the type specified in 'type' attribute has non-default constructor.
    <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"

Indices and tables