NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Discovering Type Information at Runtime

The Reflection API provides access to type information at run time (see Type). The primary users of the Reflection services are script engines, type viewers, compilers, and serializers.

The term reflection refers to the ability to reflect (as a mirror would) the type information of an object. This includes details about the assembly in which the type is defined as well as the members of the type. The following are examples of details obtainable through reflection: the signature of a method, information about a property, information about a field, a list of the methods defined within a class, and a list of classes contained within a module. Using this information you can, for example, create an instance of a class, or bind to an existing object and invoke its methods or access its fields.

The primary means of accessing type information is the Type class. The runtime creates a Type when it loads a class. The runtime creates only one Type per type. Type objects are accessible through the various methods provided by Type and Assembly, as well as through the Object.GetType method. Once a reference to a Type object is obtained, you can access information about the members of a type and invoke those members through instances of the MemberInfo class and its subclasses.

In addition to the ability to reflect type information at run time, there are classes that enable types to be built at run time. These classes belong to System.Reflection.Emit namespace (see the System.Reflection.Emit overview). Intermediate language (IL) is actually written at run time and can be persisted in the NGWS runtime file format. This feature is used by scripting engines, and results in a performance gain because scripts are compiled once and executed many times.