PART I
C h a p t e r 1 7 :
R u n t i m e T y p e I D , R e f l e c t i o n , a n d A t t r i b u t e s
465
PART IPART I
Using Reflection
Using
Type
’s methods and properties, it is possible to obtain detailed information about a
type at runtime. This is an extremely powerful feature, because once you have obtained
information about a type, you can invoke its constructors, call its methods, and use its
properties. Thus, reflection enables you to use code that was not available at compile time.
The Reflection API is quite large, and it is not possible to cover the entire topic here.
(Complete coverage of reflection could easily fill an entire book!) However, because the
Reflection API is logically designed, once you understand how to use a part of it, the rest
just falls into place. With this thought in mind, the following sections demonstrate four key
reflection techniques: obtaining information about methods, invoking methods, constructing
objects, and loading types from assemblies.
Do'stlaringiz bilan baham: |