Hi Ryan,

Indeed, all I need to do is find a class which implements a certain
interface, and the return value from one of it's standard readonly
properties. I've got it working now and it's really cool. Next up: an
autocomplete list that shows all existing class names.

Cheers,
David

----- Original Message -----
From: "Ryan Heath" <[EMAIL PROTECTED]>
To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM>
Sent: Wednesday, June 22, 2005 3:54 PM
Subject: Re: [ADVANCED-DOTNET] Searching classes in an assembly


Hi David,

you could use

foreach( Assembly a in AppDomain.CurrentDomain.GetAssemblies())
foreach( Type t in a.GetTypes())
{
 if ( t.GetInterface( typeof(IYourInterface).Name) != null)
 {
   IYourInterface obj =
(IYourInterface)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(
a.FullName, t.Name);
   ... use obj
 }
}

but I do not understand the why the interface should return the name
of the class,
you already know the name of the class via its type...

HTH
// Ryan

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

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

===================================
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