I am trying to resolve dependencies based on a condition.
private static readonly Dictionary<string, Action<ContainerBuilder>> QRTypeDictionary =
new Dictionary<string, System.Action<ContainerBuilder>> () {
{ "REST" , (builder)=> builder
.RegisterType<RestPublisher>()
.As<Publisher>()},
{ "DB" , (builder)=> builder
.RegisterType<DBPublisher>()
.As<Publisher>()}
}
I am just looking to make sure if this is the only way to resolve dependencies based on conditions. I have been using Ninject so far and am looking for something like the following:
kernel.Bind<Publisher>()
.To<DbPublisher>()
.When(x => Defs.AppSettings.PublisherType == "DB")
Just want to make sure I am doing the right thing with Autofac
Defs.AppSettings.PublisherTypea configuration value that needs an application restart to change, or can it change from time to time (between requests for instance)? - Steven