使用StructureMap链接容器

3

在StructureMap中是否可以像WindsorContainer.AddChildContainer()一样将容器链接在一起?

我想要实现三个容器级别; - 1个页面请求级别 - 1个会话级别 - 1个应用程序级别

然后将它们链接在一起,以便只向“基本级别”容器发出一个实例请求。

容器的级别并不重要,重要的是它们是否有能力链接在一起。

1个回答

1

这似乎可以解决问题,不确定是否有更好的方法或者会有什么影响。目前看起来还不错...

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

其中parentContainer和childContainer都是StructureMap.Container


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接