Chapter 11. Reflection and Code Attributes
Managed code written for the .NET Framework is always accompanied by various kinds of metadata. This metadata controls everything from defining the list of referenced assemblies that an application needs to run properly, to simpler information such as the product version, product name, and so on.
This metadata is stored on disk, but it is also available to managed code at runtime. While the managed code is running, it can, at any time, make queries against the metadata associated with it. In addition to this metadata, type information including class definitions, members, properties, attributes, and instance data is also available.
The mechanism that makes all of this available is called reflection. Reflection allows managed code to not only inspect metadata about itself, but also about any other code that might be running at the same time. This chapter will show you how to use reflection to discover type and metadata information at runtime, and how to use custom code attributes to create your own runtime-discoverable metadata about your code.
WHAT YOU NEED
REFLECTION AND CODE ATTRIBUTES AT A GLANCE