Chaining containers with StructureMap

自闭症网瘾萝莉.ら 提交于 2019-12-13 14:18:10

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/336990/chaining-containers-with-structuremap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!