Microsoft Visual C#.NET 2003 Kick Start

Handling Metadata in C#

In the previous chapter, we started discussing metadata , the information a module can store about its types, code, methods , and so on. In this chapter, we're going to continue discussing metadata as we turn to attributes and reflection.

As we've seen throughout the book, attributes let you specify metadata, including directives to the compiler, in your code. You can read this metadata yourself with tools like ILDASM and others, and you can also access it in code, as we're going to see. Reflection , introduced in this chapter, is a set of techniques that allows an application to read and work with its own metadata. Custom attributes of the kind we'll see in this chapter can be very useful in the reflection process. One reflection technique, reflection emit , lets you actually create methods on the fly, from scratch (you're responsible for writing them in MSIL). We're going to see how that works in this chapter.

We'll start with attributes. There are two kinds of attributes in C#built-in and customand we'll take a look at the built-in ones first.

Категории