C# dependency injection - how to you inject a dependency without source?
Posted
by Phil Harris
on Stack Overflow
See other posts from Stack Overflow
or by Phil Harris
Published on 2010-06-17T07:06:22Z
Indexed on
2010/06/17
7:13 UTC
Read the original article
Hit count: 243
Hi, I am trying to get started with some simple dependency injection using C# and i've run up against an issue that I can't seem to come up with an answer for.
I have a class that was written by another department for which I don't have the source in my project. I wanted to inject an object of this type though a constructor using an interface, but of course, i can't change the injected objects implementation to implement the interface to achieve polymorphism when casting the object to the interface type.
Every academic example I have ever seen of this technique has the classes uses classes which are declared in the project itself. How would I go about injecting my dependency without the source being available in the project?
I hope that makes sense, thanks.
© Stack Overflow or respective owner