As of September 2023 this repository is archived; no further development will happen here and I am retiring FlexDi. Prompted by issue #20 & issue #18, I have moved future development to CSF.Extensions.DependencyInjection.
That project is based on extending Microsoft's standard/minimal DI container instead of writing a whole new DI container from scratch.
A small dependency injection container for .NET, inspired by BoDi.
Comprehensive documentation is available in the FlexDi wiki. This is some minimal sample code to create a container, register a component and resolve it right away. Firstly though, you will want the FlexDi NuGet package.
using CSF.FlexDi;
var container = Container
.CreateBuilder()
// Call other methods from the builder if desired,
// in order to configure container options & functionality
.Build();
container.AddRegistrations(x => {
x.RegisterType<MyServiceType>()
.As<IServiceInterface>();
});
var myService = container.Resolve<IServiceInterface>();
FlexDi may be used as a drop-in replacement for BoDi, via a compatibility package. The assembly contained within that NuGet package provides copies of BoDi's public types, exposing the same API. The FlexDi container wrapped by the BoDi compatibility assembly is preconfigured with options to mimic BoDi's functionality and behaviour.
The FlexDi wiki has a section dedicated to using FlexDi as a replacement for BoDi.
FlexDi is the copyright of various authors. It is released under the terms of the Apache License v2.
CI builds are configured via AppVeyor for both Linux & Windows.