我有以下代码:
public class TestClass
{
public string Foo { get; set; }
public ITest<string> Test { get; set; }
}
[Convertible]
public interface ITest<T>
{
T Param { get; set; }
}
[Convertible]
public class Test<T> : ITest<T>
{
public T Param { get; set; }
public string OtherParam { get; set; }
}
我想用它
WindsorContainer container = new WindsorContainer(new XmlInterpreter());
var t = container.Resolve<TestClass>();
我不想使用 Fluent 配置,而是使用 xml 配置。此外,我想逃避 ITest 组件的显式注册。就像它可以只配置一个组件注册(TestClass),并且所有参数都可以在 <parameters> 节点中提供。但目前我未能创建工作配置,它创建了null TestClass 对象或 TestClass 并将 Test 属性设置为null。
我的配置:
<component id="Service.Main"
type="ConsoleApplication1.TestClass"
lifestyle="transient">
<parameters>
<foo>foo string</foo>
<Test>
<Param>param string</Param>
<OtherParam>sdgsdfgdf</OtherParam>
</Test>
</parameters>
</component>
也许有人可以建议正确的配置?谢谢