2012-06-07 119 views
0

我在项目中使用Castle Windsor并且目前遇到了配置文件的问题,其中很多都是混乱的。所以我决定对它们进行结构化。
我用一个主要的xml文件初始化windsor工厂,并根据它的内容从xml文件中注册其余的组件。
工厂从xml配置文件初始化后,是否有机会注册组件。Castle Windsor从XML中添加组件

水木清华这样的:

ComponentFactory.Initialize(Configuration.FromXmlFile("Main.xml")); 
var config = ComponentsFactory.Resolve<MainConf>(); 
foreach(var xml in config.XMLList) 
{ 
    ComponentFactory.RegisterFromXML(xml) 
} 
+0

你说哪个配置文件? windsor或NHibernate? – Firo

+0

温莎,对不起,我会编辑主题 –

回答

1

以下方法可用于:

<castle> 
    <include uri="file://config_part_1.xml" /> 
    <include uri="file://config_part_2.xml" /> 
    <include uri="file://SomeConfigurationFolder/config_part_3.xml" /> 
    <include uri="file://SomeConfigurationFolder/config_part_4.xml" /> 
</castle> 

路径是相对于项目文件夹。

不确定它是否符合所有要求,但它可以用于从逻辑上将城堡配置分配到一组文件中。