I have
interface IConfigurationSource
{
....
}
and
class FileConfigurationSource : IConfigurationSource
{
FileConfigurationSource(string fileName)
{
...
}
}
I have to use FileConfigurationSource in two different places with say “Config1.xml” in ClassA and “Config2.xml” in ClassB. How do I used ninject to supply the right parameter based on context or is that violating IoC/DI pattern?
Thanks,
.WhenInjectedInto can be used to change what is injected in differing targets. This doesn’t violate IoC IMHO because you are making it someone elses responsibility to determine the dependency not the class itself.
Something like