GenericsNReflect

This pages gives an intoduction of the way generics are reflected by NReflect.

Overview

The following figure shows the important types for the reflection of generics.

Generics
Figure 1: Class diagram showing all types belonging to the reflection of generics.

IL allows two things to be a generic: Some types (namely delegat, interface, class and struct) and methods. So each of the corresponding NReflect types implements the NReflect.IGeneric interace (see figure 1). This interface defines two properties: one to get a value indicating if the member or type is generic one. The second one gets a list containing information about the type parameters. Each type parameter is stored as a NReflect.NRParameters.NRTypeParameter. This is necessary because a type parameter can have some constraints like the following:

1public class MyGenericClass<T, S> where T : class, IComparable, IConvertible, new()
2                                  where S : class, new()
3{
4  // ... 
5}
All the information is reflected by NReflect.

See Also

Reference

Other Resources