I hope this question is not too stupid, I am trying to catch more advanced programming principles and thus have been trying to get used to Injection Dependency using Ninject.
So, my model is divided into several different DLL projects. One project defines model specifications (interfaces), and a couple of others implement these interfaces. All model projects must use some kind of database system, so they all need access to another .dll, which implements all my database logic. It is important that they all can access the same instance of my database object, so if it werenβt enough just to create one instance for each model.
I'm not quite sure how to achieve this using dependency injections. My first thought was to create a separate DI project and link all the interfaces to their respective implementation, so the DI project needed links to all other projects (model and implementation interfaces, database system, etc.). Again, models need access to the DI project because, for example, they will need to query the database system from the DI (Ninject) system. Of course, this will create a circular link (link the DI project with the model and model to the DI project), so this is not possible.
In short, I need a programming pattern that allows me to associate model interfaces with their implementations, but also allows model implementations to request other Ninject dependencies, for example.
IModel1 -> Model1 IModel2 -> Model2 (different project) IDatabase -> Database (different project) Model1 -> request IDatabase -> get Database instance Model2 -> request IDatabase -> get the same Database instance
I would be glad to receive a couple of suggestions, at the moment I'm stuck out of ideas;) Thank you!
source share