-
Notifications
You must be signed in to change notification settings - Fork 2
Simple Usage of Lightweight IOC Container
This is a simple usage guide of the Lightweight IOC Container.
The easiest way to instantiate the IocContainer
is to create an instance of it at the start of your application:
IocContainer container = new IocContainer();
To be able to resolve instances from the IocContainer
, you need to register them first.
There are multiple ways to accomplish this and the best solution depends on the complexity of your project.
In this simple usage guide we will only take a look at the most straightforward way that is to just register the interfaces and their classes with the IocContainer
:
container.Register<IFoo, Foo>();
There are multiple lifestyles available, make sure you choose the correct one for your need.
To resolve an instance with the IocContainer
, do the following:
IFoo interface = container.Resolve<IFoo>();
When your application is finished make sure to dispose your IocContainer
:
container.Dispose();
Still questions or problems?
Create a new Issue.
- Home
- Install Lightweight IOC Container
- Usage
- Advanced usage
- Detailed documentation