On 2005-06-22 14:26, David Rutten wrote:
Hello all,

I've been wondering how to do something tricky, and I can'tfind a single
reference about it in the msdn docs...

Strange....

Imagine I have a regular windows program, with a bunchof classes that all
implement a certain interface. There are also lots of other classes that do
not implement it.
The interface defines a readonly property called Name which returns the
name of the class.
Now I would like add a textbox, where the user can type a string at
runtime, and then the app has to find (and initialize) the class which name
equals the entered text.

But for this to work I need to do 2 things I can't find:
1) search an assembly at runtimefor classes that implement an interface
See the System.Reflection.Assembly.GetTypes(...)
And System.Type.GetInterfaces()

2) create an instance of a class using a variable type (or don't I?)

See System.Activator.CreateInstance(...)

Regards,
Bogdan

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to