Background: I wanted to distribute a library to some other developers (something along the lines of an SDK or toolkit abstracting some internal web services). I'm using Autofac in order to inject different versions of the underlying services, mostly for stubbing. I want to distribute this assembly to a wide range of developers: users that understand IoC, and users that don't.
For any savvy developers, they can create their own implementations to be injected. Otherwise, a dev should be able to use the assembly w/o config and never know or care IoC is happening under the hood.
Fun stuff: I can provide Xml configuration to Autofac, or I can programatically configure components (the latter being the preferred method). In this case, I won't know what's been configured until run-time, hence the possible need for Xml config. Is there a way to make Autofac use the Xml configuration if it exists, else ignore it if none has been provided?
Note: I can implement this by hand by inspecting configuration for a specific section ("autofac"); if it's not there, then don't call
builder.RegisterModule(new ConfigurationSettingsReader());
Is there a better way to do this than inspecting the configuration manually (preferably something magical hidden within Autofac, as it seems to be able to do anything you ask of it!)