parent
d11ee006e5
commit
f3f2c77f43
1 changed files with 35 additions and 1 deletions
@ -1 +1,35 @@ |
|||||||
This is an advanced usage guide of the Lightweight IOC Container. |
This is an advanced usage guide of the Lightweight IOC Container. |
||||||
|
|
||||||
|
## Bootstrapping container |
||||||
|
|
||||||
|
The best way to instantiate the `IocContainer` is to create a `Bootstrapper` class. This `Bootstrapper` is there to instantiate the `IocContainer` as well as installing all the `IIocInstaller`s. |
||||||
|
|
||||||
|
Example `Bootstrapper`: |
||||||
|
|
||||||
|
```c# |
||||||
|
public class Bootstrapper |
||||||
|
{ |
||||||
|
public IIocContainer InstantiateContainer() |
||||||
|
{ |
||||||
|
IIocContainer kernel = new IocContainer(); |
||||||
|
|
||||||
|
return kernel.Install(new Installer()); |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
## Register types with `IIocInstaller`s |
||||||
|
|
||||||
|
The easiest way to register classes with the `IocContainer` is to use `IIocInstaller`s and install them in the `Bootstrapper`. |
||||||
|
|
||||||
|
Example `IIocInstaller`: |
||||||
|
|
||||||
|
```c# |
||||||
|
public class Installer : IIocInstaller |
||||||
|
{ |
||||||
|
public void Install(IIocContainer container) |
||||||
|
{ |
||||||
|
container.Register(RegistrationFactory.Register<IFoo, Foo>()); |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|||||||
Loading…
Reference in new issue