Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chaining containers with StructureMap

Is it possible to link containers together in StructureMap like it is in WindsorContainer.AddChildContainer()?

I want to achieve having 3 container levels; - 1 page request level - 1 session level - 1 application level

These would then be chained together so only one instance request would be made to the "base level" container.

The levels of container are unimportant really, just whether there is the ability to link them together.

like image 488
Xian Avatar asked Apr 23 '26 22:04

Xian


1 Answers

This seems to do the trick, not sure if there is a better way or what the implications are. So far looks ok...

childContainer.PluginGraph.Registries.ForEach(
  registry => parentContainer.Configure(expression => expression.AddRegistry(registry))
);

where parentContainer & childContainer are both StructureMap.Container

like image 180
Xian Avatar answered Apr 27 '26 15:04

Xian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!