Automatically resolve certain services when scope opens

65 views Asked by At

I need a scoped service A that reacts on events from service B, and then does something on service C.

In my architecture I have marked those kinds of services with a marker interface. The service subscribes to event sources from the injected service B in the constructor.

The problem is that I have to force the resolution of the service when the scope opens, because the service A has to subscribe to service B`s event source.

Is there a way to force certain scoped services to be resolved immediately after the scope has been opened?

Or maybe is there another way to program this?

I have tried to force the resolution. For example, in a Blazor Application I have to add a "scope bootstrap service" to force the resolution of certain services that needs to react on events. But I have to add it to every single page. I think there has to be a more elegant solution.

0

There are 0 answers