I have a core set of libraries that are delivered and work "out of the box". Meaning that the services are all wired up inside. I would like to have the ability to modify the core library (without modifying the library itself).
With that said, is there an Unbind/Rebind support in SimpleInjector? I didn't see any publicly visible methods on the container. I did find a private dictionary of registrations that I can get to with reflection.
Does anyone see a reason why I can't remove items from this private dictionary (to then re-add) at runtime with reflection? Is there a method I am missing?
Removal of registrations is not possible. Overriding registrations however is. You will have to flag the container to allow this:
var container = new Container();
container.Register<IService, FirstService>();
container.Options.AllowOverridingRegistrations = true;
// Replaces the former registration
container.Register<IService, AnotherService>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With