While registering components in Castle Windsor, how do we bind specific implementation of an interface to a component that has a dependency on that interface. I know in adva
The above answers lead me to inline dependencies and the feature service override
Here is the registration code:
container.Register(Component.For().ImplementedBy().Named("nortonService"));
container.Register(Component.For().ImplementedBy());
container.Register(Component.For().ImplementedBy());
container.Register(
Component.For().ImplementedBy().Named("mcafeeService")
.DependsOn(Dependency.OnComponent())
);
IReport mcafeescan = container.Resolve("mcafeeService");
mcafeescan.LogReport();
IReport nortonscan = container.Resolve("nortonService");
nortonscan.LogReport();
Output:
McAfee Scan has Logged data to a database
Norton Scan has Logged data to a file