1

We've created some domain services. On top of our services, we've added a Web Api layer on top to allow RESTFUL interactions with our services. We are using StructureMap for IOC. To get this to work I had to reference the domain and repository projects to our Web Api project. I want to avoid this.

With these references, it could allow developers to start referencing domain objects or repositories in our service layer. Through code reviews we can prevent that but I'd prefer to remove the references completely.

Our container is registered in this manner:

IContainer container = IoC.Initialize();
GlobalConfiguration.Configuration.DependencyResolver = new StructureMapDependencyResolver(container);

[Service Layer] --> [Domain Services] -- >[Domain Models] and [Repositories]

How do I register these dependencies in our Domain Services but not the Web Api Service Layer? Or have an IoC container for the Web Api Layer and then one for the Domain Services? Domain Services is nothing more than a Façade/Orchestration. It can be consumed by a Web Api Service Layer, WCF Service, or directly from applications like WPF or WinForms.

Thoughts?

Markus Bruckner
  • 2,852
  • 2
  • 24
  • 29
  • 1
    Strongly related: https://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-entry-application – Steven May 09 '14 at 06:48
  • @Steven I do see the relation but no clear direction. If I am using my service layer as an entry point to my domain, then some say to allow the references. Others say to create a pure DI project that will act as a bootstrap to all of my dependencies. – Daniel Dority May 09 '14 at 15:13

0 Answers0