I have 3 C#.NET assemblies:
Assembly A: Calls methods of Assembly C, which implements an interface in
Assembly B, therefore, must reference both B and C (unless late binding is
used)
Assembly B: Contains the interface implemented by C, and also referenced by
A
Assembly C: Implements interface located in Assembly B
So, now A is dependent on C (and everything C is dependent on), even though
it is only treated as a B, for example:
in B: (the interface)
public interface Runner {
void Run();
}
in C: (the implementation)
public class RunnerImp : Runner {
public void Run() {
Console.Write("Running");
}
}
in A: (the dependency I want to avoid)
class Engine {
Runner myRunner = new RunnerImp();
myRunner.Run();
}
So, even though I tried to do DIP, I failed.
How to get around this dependency without doing late-binding (using
Activator class) to RunnerImp class?
Use of abstract factory has been suggested, but it seems to me that I still
depend on the abs factory, which then depends on the concrete factory, which
then depends on the concrete product and all it's dependencies (actually, on
all the concrete products' dependencies). I thought there might a way around
this? Or am I trying to do something that isn't possible?
Thanks.