Is it possible to share/use the nested container created by the WebAPI dependency resolver?
The structuremap.web (I'm using structuremap and NServiceBus.StructureMap and UseContainer<StructureMapBuilder>(x => x.ExistingContainer(container))
) package provides IDependencyResolver
, IDependencyScope
implementations that are pretty self explanatory - the resolver is created with the root container and when a scope is requested, it returns a new scope that is created with a nested container from the root.
What I want to know is that in the context of a WebAPI endpoint, can I share that nested container with NSB. Looking here, the structure map builder does pretty much what the WebAPI resolver does - container.GetNestedContainer(). This means I get two nested containers for each (HTTP) request that uses the bus.
My use case is that I want to create a sort of headers bucket that I can put headers into from a DelegatingHandler
and then pull them back out of in an OutgoingMessageMutator
.