views:

216

answers:

1

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.

A: 

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

Xian