Reflector
Requirements
This demo requires Microsoft NGWS
Description
The purpose of this demo is to introduce NGWS Reflection is a feature in NGWS that allow object inspection and dynamic invocation. The reflector program uses NGWS reflection to inspect the methods and properties of the class named on the command line at runtime. You can also invoke the classes methods at runtime by using the command line switches.
Build Instructions
Please use the included makefile to build the sample.
Execution Instructions
Run the program with the name of the class you want to inspect on the command line. For example:
C:\>reflector Factorial
Class: Factorial
The class name is case sensitive so you must type Factorial with an upper case F. The reflector program responds by displaying the name of the class. To dispaly the names and signatures of all methods of the Factorial class use the m option and the v option along with the class name:
C:\>reflector -m v Factorial
Class:
Factorial
Methods (12)
Microsoft/Runtime/Class GetClass ()
Microsoft/Runtime/String ToString ()
bool Equals (Microsoft/Runtime/Object)
int GetHashCode ()
void Wait ()
void Wait (int)
void Notify ()
void NotifyAll ()
void Notify (bool)
int GetObjectContext ()
int Value (int)
int calc (int)
The reflector program displays the names and signatures of only those methods implemented by the Factorial class. To invoke one of Factorials methods, specify the name of the method you want to invoke with the m option and pass any parameter to the method with the i option. For example, to invoke the Factorial.Value(5) type:
C:\>reflector mValue i"5" Factorial
Class:
Factorial
Methods (1)
Invoking method "Value" on class "Factorial"
With 1 argument:
Argument 1: "5"
Factorial::Value:5
Factorial::Value returning:120
Invocation Results: (Microsoft.Runtime.Integer4) 120
The name of the method is also case sensitive.