A lightweight IOC Container that is powerful enough to do all the things you need it to do.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Simon G. d7503ba68d
- add factoryGenerator nuget badges to readme
2 days ago
.github/workflows - update actions 4 days ago
Debug.LightweightIocContainer.FactoryGenerator - fix generic arguments and nullability 3 days ago
LightweightIocContainer - make internals visible to new test lib 3 days ago
LightweightIocContainer.FactoryGenerator - new constraint must be last 2 days ago
LightweightIocContainer.Validation - update versions and readmes 5 days ago
Test.LightweightIocContainer - update nuget packages 3 days ago
Test.LightweightIocContainer.FactoryGenerator - remove unneeded annotations 3 days ago
Test.LightweightIocContainer.Validation - update nuget packages 3 days ago
.gitattributes - add .gitattributes 7 years ago
.gitignore - don't ignore all launchSettings 5 days ago
LICENSE.md - add .md file extension 6 years ago
LightweightIocContainer.sln - add test lib for generator 3 days ago
LightweightIocContainer.sln.DotSettings - allow async onCreate method by introducing async resolve 1 year ago
README.md - add factoryGenerator nuget badges to readme 2 days ago

README.md

Lightweight IOC Container

A lightweight IOC Container that is powerful enough to do all the things you need it to do.

GitHub Actions

Nuget Nuget Nuget (with prereleases)

Nuget Nuget Nuget (with prereleases)

Nuget Nuget Nuget (with prereleases)

Get started with the Lightweight IOC Container

How to install

The easiest way to install the Lightweight IOC Container is by using NuGet through the .NET CLI:

> dotnet add package LightweightIocContainer --version 5.0.0

Example usage

  1. Instantiate IocContainer:

    IocContainer container = new();
    
  2. Install IIocInstallers for the container:

    container.Install(new Installer());
    
  3. Resolve one instance from the container:

    IFooFactory fooFactory = container.Resolve<IFooFactory>();
    
  4. Use this instance to create what your application needs:

    IFoo foo = fooFactory.Create();
    
  5. When your application is finished, don't forget to dispose your IocContainer:

    container.Dispose();
    

Validation

There is the option to install the LightweightIocContainer.Validation package:

> dotnet add package LightweightIocContainer.Validaton --version 5.0.0

With this you can validate your IocContainer setup by using the IocValidator in a unit test:

[TestFixture]
public class IocValidationTest
{
    [Test]
    public void ValidateIocContainerSetup()
    {
        IocContainer container = new();
        container.Install(new Installer());

        IocValidator validator = new(container);
        validator.Validate();
    }
}

If this test is successful, everything is correctly installed and can be resolved by the IocContainer. By going through the thrown exceptions in case of a failed test you will see what is not working correctly with your current setup.

Demo Project

There is a demo project available where you can check out how different functions of the Lightweight IOC Container can be used.