Robertscorp / Slender.Dependencies

A .NET library to register your project's dependencies without being tied to a specific dependency injection container.
MIT License
0 stars 0 forks source link

Change Dependency so it can't put itself into an invalid state #23

Closed Robertscorp closed 9 months ago

Robertscorp commented 1 year ago

The Behaviour is able to do whatever it wants to the Dependency. That's great for flexibility, but not great for consistency. Probably just throw exceptions in the setter if the operation would put the Dependency in an invalid state (i.e. multiple implementation mechanisms all being set at the same time)

Robertscorp commented 1 year ago

Alternatively, the DI container can support multiple mechanisms at the same time. That means that it's not invalid. Also, that means that the default behaviour is not flexible enough - it should support either only a single implementation, or as many implementations as you want. That also means that there should be multiple Implementation Instances and Implementation Factories

Robertscorp commented 9 months ago

This ticket relates to multiple implementations being added to a single dependency, which is a valid scenario. If a dependency should only have a single implementation, either use the standard dependency and lock it, or write a custom IDependency. Otherwise, the dependency class handles this scenario as of #34