Microsoft Visual C#.NET 2003 Kick Start

Reflection is a set of techniques that lets code read and work with its own metadata, or that of other code, and it's supported by classes in the System.Reflection namespace, such as System.Reflection.MemberInfo (which is the class that we're going to use to read metadata from the custom Author attributes we just created). There are four parts to reflection:

  • Accessing metadata of the kind stored in attributes.

  • Discovering and examining types , including creating objects from those types.

  • Late binding , also called dynamic invocation , which lets you create objects on the fly and use their properties and methods .

  • Reflection emit , which lets you create new types at runtime and use those types in your code.

We'll take a look at each of these four techniques in the remainder of this chapter.

Категории