使用StructureMap,当默认的具体类型在一个注册表中的定义,能不能在其他注册表重新定义? [英] Using StructureMap, when a default concrete type is defined in one registry, can it be redefined in another registry?

查看:172
本文介绍了使用StructureMap,当默认的具体类型在一个注册表中的定义,能不能在其他注册表重新定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在项目中我的工作我有一个StructureMap注册表中的主要Web项目,另一个注册表我的集成测试。在某些测试中我电汇了Web项目的注册表,这样我就可以得到物品从容器进行检测。

In the project I'm working on I have a StructureMap registry for the main web project and another registry for my integration tests. During some of the tests I wire up the web project's registry, so that I can get objects out of the container for testing.

在一种情况下,我希望能够以取代从网上注册一个默认的具体类型与一个在测试注册。

In one case I want to be able to replace a default concrete type from the web registry with one in the test registry.

这可能吗?

你怎么办呢?

推荐答案

是的,你可以,容器将成为了其有史以来键入的最后一个定义(根据我的测试)。我推论(但我不确定),我的错误是,我打电话后,我注册了一些类型,​​它得到了重新注册回到它的原 IInitializationEx pression.Scan 机制设置。

Yes you can, the container will serve up which ever type is last defined (according to my tests). I theorize (but I am unsure) that my mistake was that I called the IInitializationExpression.Scan mechanism after I registered some type and it got reregistered back to it's original setting.

这篇关于使用StructureMap,当默认的具体类型在一个注册表中的定义,能不能在其他注册表重新定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆