温莎集装箱:如何指定公共财产不应由集装箱填充? [英] Windsor Container: How to specify a public property should not be filled by the container?

查看:85
本文介绍了温莎集装箱:如何指定公共财产不应由集装箱填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实例化一个类时,默认情况下,Windsor将该类的所有公共属性视为可选依赖项,并尝试满足它们。就我而言,这会创建一个相当复杂的循环依赖关系,从而导致我的应用程序挂起。

When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang.

我如何明确告诉温莎城堡它不应该试图满足公共财产的要求?我认为必须有某种程度的属性。但是我找不到它,所以请让我知道合适的名称空间/程序集。

How can I explicitly tell Castle Windsor that it should not be trying to satisfy a public property? I assume there must be an attribute to that extent. I can't find it however so please let me know the appropriate namespace/assembly.

如果有没有属性的方法(例如Xml Configuration或configuration),最好通过代码),因为发生这种情况的特定库迄今不需要依赖城堡。

If there is any way to do this without attributes (such as Xml Configuration or configuration via code) that would be preferable since the specific library where this is happening has to date not needed a dependency on castle.

推荐答案

我创建了一个工具来解决此问题:

I created a facility to help with this:

  • Castle.Facilities.OptionalPropertyInjection

这篇关于温莎集装箱:如何指定公共财产不应由集装箱填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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