SimpleInjector Unbind / Rebind

I have a basic set of libraries that ship and work out of the box. This means that all services are connected internally. I would like to be able to modify the main library (without changing the library itself).

With that said, is there Unbind / Rebind support in SimpleInjector? I have not seen any public methods in the container. I found a private registration dictionary with which I can reflect.

Does anyone see the reason why I cannot remove elements from this private dictionary (so I can add them again later) at runtime with reflection? Is there a way that I'm missing?

+6
source share
1 answer

Deletion of registrations is not possible. However, redefining registrations. You will need to specify a container to enable this:

var container = new Container(); container.Register<IService, FirstService>(); container.Options.AllowOverridingRegistrations = true; // Replaces the former registration container.Register<IService, AnotherService>(); 
+4
source

All Articles