diff --git a/Advanced-Usage-of-Lightweight-IOC-Container.md b/Advanced-Usage-of-Lightweight-IOC-Container.md index efa9aa2..2ff416d 100644 --- a/Advanced-Usage-of-Lightweight-IOC-Container.md +++ b/Advanced-Usage-of-Lightweight-IOC-Container.md @@ -1 +1,35 @@ -This is an advanced usage guide of the Lightweight IOC Container. \ No newline at end of file +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()); + } +} +```