On my development machine, I am currently registering my components in Castle Windsor using the fluent interface, eg.:
container.Register(
Component.For<IRelationCostMatrix>()
.ImplementedBy<DefaultCostMatrix>(),
Component.For<SemanticGraph>()
.UsingFactoryMethod(GetSemanticGraph)
.LifeStyle.Singleton /* etc. */
);
In addition, some of the projects hosting implementations of my interfaces use installers. These installers mostly follow the same approach, however some times are installed via reflection (ie. registration in an foreach loop of all types implementing IMyInterface).
I was wondering if it was possible to easily transform this configuration into the XML configuration format prior the project’s deployment, for instance something along the lines of container.Kernel.ConfigurationStore.WriteTo("cfg.xml"). Is there an easy way to do it, or is it better to do that manually?
Thanks in advance,
Manny
It’s impossible to do this generically. Code is more expressive than XML config.
Furthermore, I don’t think it’s even a good idea. Most stuff should not be configurable via XML. Only make configurable what’s truly configurable. Most of the time you can simply make your components configurable via some simple AppSettings keys in your web.config/appconfig.