- add first draft of advanced usage

master
Simon Gockner 7 years ago
parent d11ee006e5
commit f3f2c77f43
  1. 36
      Advanced-Usage-of-Lightweight-IOC-Container.md

@ -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…
Cancel
Save