Castle Windsor and its own configuration file
- by Coppermill
I am using Castle Windsor for IoC, and have the configuration held in the web.config/app.config, using the following factory:
public static TYPE Factory(string component)
{
var windsorContainer = new WindsorContainer(new XmlInterpreter());
var service = windsorContainer.Resolve<TYPE>(component);
if (service == null)
throw new ArgumentNullException(string.Format("Unable to find container {0}", component));
return service;
}
and my web.config looking like this:
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
</configSections>
<castle>
<components>
<component id="Data" service="Data.IData, Data" type="Data.DataService, Data"/>
</components>
</castle>
<appSettings>.......
Which works fine, but I'd like to place the configuration for Castle Windsor in a file called castle.config. How do I do this?