Public Interface Iwriter
{
VoidWrite ();
}
Public Class Logwriter: iwriter
{
Public Static Int Typeid;
Iwriter members # Region Iwriter members
Public Void Write ()
{
//Throw new exception ("the method or operation is not implemented .");
Console. writeline (typeid );
}
# Endregion
}
Assembly = Assembly. getexecutingassembly ();
Module [] modules = Assembly. getmodules ();
If (Modules ! = Null )
{
Foreach (Module OBJ In Modules)
{
Type [] types = OBJ. gettypes ();
Foreach (Type objtype In Types)
{
If (Objtype. Name = " Logwriter " )
{
Try
{
Objtype. invokemember ( " Typeid " , Bindingflags. setfield | Bindingflags. Public | Bindingflags. Static, Null , Null , New Object [] {1200} );
Iwriter writer = (Iwriter) activator. createinstance (objtype, False );
Writer. Write ();
}
Catch (Exception ERR)
{
Console. writeline (ERR. Message );
}
}
}
}
}
Useful classes:
Assembly
Module
Type
Activator
System. Reflection namespace is essential before using these classes!