Castle Windsor: how to know that the container has been initialized or configured?
I'm using Castle Windsor with a configuration from my App.config file.
In the code I use :
IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
to get the container.
But for some configurations of my application I don't want to use CastleWindsor (for some migration issues...) and therefore, I don't want to add any Castle section in my App.config.
And the problem is that if there is no castle config, then
IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
throws an exception "Could not find section 'castle' in the configuration file associated with this domain."
So basically in my code I want to do something like:
if (IsCastleWindsorInitialized()) {/* do something */ } else { /* do something else */ }
where 'IsCastleWindsorInitialized()' returns true when 开发者_运维技巧the App.config contains a castle section.
In order to implement that function I can certainly use the ConfigurationManager but I'm wondering if I can use Castle Windsor API to do that.
I would probe the app.config with a ConfigurationManager.GetSection("castle") (that is, if you use XML-only configuration)
精彩评论