2
如何讓Windsor尊重可選的注入構造函數參數?Windsor可選的構造函數參數
我試着製作一個IContributeComponentModelConstruction,它循環遍歷每個構造函數的每個ParameterInfo,並檢查它是否爲IsOptional,然後相應地在Windsor Dependency對象上設置IsOptional,但這似乎並沒有起到作用。我仍然得到「由於依賴......等原因而無法實例化」。
謝謝。
UPDATE:
我使用2.5.2.0爲Silverlight 4.0,可以與以下的重現:
var container = new WindsorContainer();
container.Register(Component.For<TestClass>());
container.Resolve<TestClass>(); //boom
public class TestClass
{
public TestClass(ITest test=null)
{
}
}
public interface ITest
{
}
Missing dependency.
Component TestClass has a dependency on ITest, which could not be resolved.
Make sure the dependency is correctly registered in the container as a service, or provided as inline argument.
謝謝!它沒有自定義貢獻者,自動?或者我仍然需要自定義貢獻者? – Jeff 2010-12-10 03:43:52