Here you have a sample code. The idea is to use Reflection to discover type
information at runtime:
public interface IModuleOne
{
string GetInfo ();
}
public interface IModuleTwo
{
string GetData ();
}
public class TestClass : IModuleOne, IModuleTwo
{
public string GetInfo ()
{
return "Info";
}
public string GetData ()
{
return "Data";
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
Type[] myObjectArray= typeof(TestClass).GetInterfaces();
Console.WriteLine("The Interfaces inherited by the MyTemplate class are
:\n");
for (int index = 0; index < myObjectArray.Length; index++)
{
Console.WriteLine(myObjectArray[index].FullName + ", " +
myObjectArray[index].Name);
}
}
catch (Exception e)
{
Console.WriteLine("Exception Raised !");
Console.WriteLine("Message : " + e.Message);
}
Console.ReadLine ();
}
}
--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:bv**********@planja.arnes.si...
Hi!
Here's my problem:
Let's say I have 2 interfaces:
interface Module1
{
public void method1();
}
interface Module2
{
public void method2();
}
I'm using late binding, so at compile-time I don't know which modules I'll
be loading as I want
to provide a simple plug-in functionality.
So now I load my class from assembly.dll. How do I know which interfaces
has my class
implemented? Module1, Module2 or perhaps both or even none.
As mentioned before I would like to provide a simple plugin functionality,
similar to the one VS.NET has.
So if someone writes a plugin for my application he would implement the
IModule interface.
If the users module would like to add something to the menubar, he would
implement
IModuleMenu as well.
Is this a good way of doing this?
thanks,
saso