inversion-of-controlcastle-windsorioc-containerwindsor-facilities

How to add facility configuration in Castle Windsor v3+ using code?


In Castle Windsor v3+ the IWindsorContainer.AddFacility<T>(string idlnConfiguration) method has been deprecated. In the old version you could use this method to add dynamic configuration by calling IConfigurationStore.AddFacilityConfiguration(string key, IConfiguration config) where "idlnConfiguration" and "key" were the same in the calls.

For example:

store.AddFacilityConfiguration("quartzNet", facilityConfig);
container.AddFacility<QuartzFacility>("quartzNet");

What is the recommended way of doing this in Windsor 3? The message on the ObsoleteAttribute points at using container.AddFacility<T>() instead, but I can't see how.


Solution

  • the recommended way is to use

    container.AddFacility<SomeFacility>(f => f.Configure("me").Here());
    

    obviously the facility has to support this.