How do I dynamically point an interface to a specific class at runtime?
Posted
by
Jon
on Stack Overflow
See other posts from Stack Overflow
or by Jon
Published on 2011-02-15T14:15:22Z
Indexed on
2011/02/15
15:25 UTC
Read the original article
Hit count: 209
As a simple example, I have an xml file with a list of names of classes which actually carry out the work and all implement interface IDoWork with a method Process().
I loop through the items in the xml file. How do I actually dynamically assign the class to the interface from a string name? e.g.
var IDoWork = new "DoWorkType1"();
IDoWork.Process();
<work>
<item id="DoWorkType1">
</item>
<item id="DoWorkType2">
</item>
</work>
I want to achieve a plugin type architecture, except the plugin isn't at an assembly level only a class level within my program.
© Stack Overflow or respective owner