I am creating a node based CMS web system in asp.net mvc.
After reading several books on dependency injection, I divided my solution into several projects and used abstractions (abstract classes and interfaces).
I cannot figure out how to solve the following type of code in my web project:
myDomainObjectNode.GetChildNodes<SomeSubNodeClass>();
I could do this if the domain object had an INodeRepository reference, but that would mean that I have to carry this dependency in all the domain objects, which is a problem, especially when I have to create new instances. Does the dependency (mostly repository) in your domain object have a bad thing?
My other idea is to achieve this using extension methods. However, extension methods are static in a static class, which in itself cannot be built using IoC. I could solve this with Singleton for an INodeRepository and set it using IoC.
This doesn't seem like an elegant solution ... do you have any other ideas or input?
Thank!
source
share