结构图 202 - 为什么?
好的,我正在尝试为我向 SM 注册的类型设置属性。
这是我的一个组件中的注册表中的代码。这 在控制台应用程序的配置过程中添加注册表。 当我尝试访问实例的 EndorsementSpecs 属性时 AutoMandatoryEndorsementAggregator 对象,我得到 202。什么是 有趣的是我可以打电话 GetAllInstances>() 来自我的 控制台应用程序,它解决得很好。有什么关于 从 OnCreation 中访问此代码会导致 202?我 可以在 WhatDoIHave() 中看到我期望的一切。我也尝试过 TypeInterceptor ,得到了相同的结果。
//register all open generics
cfg.ConnectImplementationsToTypesClosing(typeof
(MandatoryEndorsementSpecBase<>));
ForSingletonOf<IMandatoryEndorsementAggregator<AutoPolicy>>()
.Use<AutoMandatoryEndorsementAggregator>()
.OnCreation((context, x) =>
{
var specs =
context.GetAllInstances<MandatoryEndorsementSpecBase<AutoPolicy>>();
x.EndorsementSpecs = specs;
})
;
OK, I'm trying to set a property on a type I'm registering with SM.
Here's the code from the registry in one of my components. This
registry is being added during the configuration from a console app.
When I try to access the EndorsementSpecs property of the instance
AutoMandatoryEndorsementAggregator object, I get the 202. What's
interesting is that I can call
GetAllInstances>() from my
console app and it resolves just fine. Is there something about
accessing this code from within OnCreation that is causing the 202? I
can see everything I expect in WhatDoIHave(). I've also tried a TypeInterceptor with the same results.
//register all open generics
cfg.ConnectImplementationsToTypesClosing(typeof
(MandatoryEndorsementSpecBase<>));
ForSingletonOf<IMandatoryEndorsementAggregator<AutoPolicy>>()
.Use<AutoMandatoryEndorsementAggregator>()
.OnCreation((context, x) =>
{
var specs =
context.GetAllInstances<MandatoryEndorsementSpecBase<AutoPolicy>>();
x.EndorsementSpecs = specs;
})
;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很抱歉转移您的真正问题,但是您是否只是想将 MandatoryEndorsementSpecBase 的所有实例注入 AutoMandatoryEndorsementAggregatory 中?
如果是这样,您可能只需将其设置为构造函数参数即可,以便它们全部自动注入。
Sorry to deflect your real questions, but are you just trying to inject all instances of MandatoryEndorsementSpecBase into AutoMandatoryEndorsementAggregatory?
If so, you can probably get away with just making it a constructor parameter so that they are all automatically injected.