我想转换如下内容:
<components> <component id=""service1"" service=""WindsorTests.IService, MyAssembly"" type=""WindsorTests.Service1, MyAssembly""/> <component id=""service2"" service=""WindsorTests.IService, MyAssembly"" type=""WindsorTests.Service2, MyAssembly""/> <component id=""consumer"" type=""WindsorTests.Consumer, MyAssembly""> <parameters> <services> <dictionary> <entry key=""one"">${service1}</entry> <entry key=""two"">${service2}</entry> </dictionary> </services> </parameters> </component> </components>
输入如下代码:
Container.AddComponentWithProperties<Consumer>(Container.ResolveAll<IService>());
任何人都知道怎么做。
注:
我正在尝试做类似于本文中描述的事情,但不使用XML: Windsor Castle :- Inject Dictionary of Interfaces via configuration
container.Register(Component.For<Consumer>() .DynamicParameters((kernel, parameters) => parameters["services"] = new Dictionary<string, IService> { {"one", kernel.Resolve<IService>("service1")}, {"two", kernel.Resolve<IService>("service2")}, } ));
见 fluent API wiki 供参考。