> I'm not sure this is possible, but is there an elegant way to ask for a list
> of objects who implement an interface?
[quoted text clipped - 5 lines]
> it is included. The shell should not have to change to accomodate new
> plug-ins.
Use one of the forms of Assembly.Load* to load the DLL, and then use
Assembly.GetTypes to get all the types within it. From there, use
if (typeof(IFileParser).IsAssignableFrom(typeToTest))
to check whether a type implements IFileParser.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Walter L. Williams - 19 May 2004 16:29 GMT
It worked! Thanks a lot.
String[] arrayDlls = Directory.GetFiles(Application.StartupPath, "*.dll");
ArrayList listParsers = new ArrayList();
for (Int32 i = 0; i < arrayDlls.Length; ++i)
{
Assembly oAssembly = Assembly.LoadFrom(arrayDlls[i]);
Type[] arrayTypes = oAssembly.GetTypes();
for (Int32 j = 0; j < arrayTypes.Length; ++j)
{
if ((typeof(IFileParser) != arrayTypes[j]) &&
typeof(IFileParser).IsAssignableFrom(arrayTypes[j]))
{
IFileParser oParser = (IFileParser)
System.Activator.CreateInstance(arrayTypes[j]);
listParsers.Add(oParser);
}
}
}
this.arrayParsers = new IFileParser[listParsers.Count];
for (Int32 i = 0; i < this.arrayParsers.Length; ++i)
this.arrayParsers[i] = (IFileParser) listParsers[i];
====================================================
Walter Williams
Software Engineer
Sawtooth Software, Inc.
http://www.sawtoothsoftware.com
----------------------------------------------------
"Do, or do not. There is no try."
> > I'm not sure this is possible, but is there an elegant way to ask for a list
> > of objects who implement an interface?
[quoted text clipped - 12 lines]
>
> to check whether a type implements IFileParser.