Castle Windsor - 在我的设施加载之前注册组件。 - 延迟加载配置文件?

时间:2010-08-21 10:52:27

标签: configuration inversion-of-control castle-windsor components

我想在设施加载之前在我的Windsor容器中注册一些组件 - (这样我就可以使用设施中的一些组件)

我当时认为应该有一些方法来初始化windsor而没有配置文件,注册一些组件,然后只加载配置? - 这会导致我的配置设施只有在我注册了我的组件后才会加载。

例如:

var container = new WindsorContainer();

//Register a custom component, which will be used in some of the facilities
container.Register(Component.For<IMyService>().ImplementedBy<MyService>());

//Now load via the configuration - unfortunately the method "Configure" doesn't exist
container.Configure(new XmlInterpreter(new ConfigResource("castle")));

感谢您的任何帮助,

谢谢!

1 个答案:

答案 0 :(得分:2)

container.Install(Configuration.FromAppConfig());

请参阅the documentation