Shared dependency registration between apps?

Let’s say I have a project with 3 applications, all of which will host a single shared service. In all 3 applications I want to wire the same data access repositories because the (shared) service depends on them. Whenever I add a new repository the service depends on, I have to add the same registration in all 3 AppHost files.

Is there a recommended approach to avoid repeating the same registrations for a service across multiple applications/apphosts? If I were to create another project and make a class with a shared method that takes the container and wires the dependencies would that be a bad idea? Or possibly inherit AppHost and make an apphost class that wires all the dependencies in the separate assembly and use that apphost in Application1, 2 and 3 instead of each of them having their own?

  • Application1 (Uses ServiceInterface1)
  • Application2 (Uses ServiceInterface1)
  • Application3 (Uses ServiceInterface1)
  • WiringAssembly? - Should I make this project, and have an apphost or shared method that does the wiring, and then call it in Application1, 2 and 3?
  • ServiceInterface1
  • ServiceModels1
  • DataAccess

It’s just code, how you choose to DRY your configuration code is ultimately a preference choice. For Gistlyn, which is available in multiple React Desktop Apps, we have a shared static class for common configuration which is called in each AppHost:

    public override void Configure(Container container)
1 Like