Attribute class. Then you can
easily associate an instance of your custom attribute to just about any entity in your assembly.
Your metadata is accessible at run time. For example, you can iterate over all the fields of an
arbitrary class type without having to know its declaration ahead of time or at compile time.
In .NET, all assemblies follow the same metadata format; you never have to worry about
consumers accessing your objects. Additionally, assembly structure and manifests mean no
more issues related to registry entries and versioning that were prevalent previous to .NET.
Reflection
With metadata, you can programmatically access and examine type definitions and the attributes
attached to them. Metadata can tell you if a particular object??™s class supports a given
method before attempting to call it or if a given class is derived from another. The process of
inspecting metadata is called reflection. Classes in the System.Reflection namespace are used
to retrieve type information at run time. Typically, you start with a System.Type object when
you reflect upon types in the assembly. Once you have a type object, you can find out if it??™s a
class, an interface, a structure, and so on, what methods it has, and the number and types of
fields it contains.
Pages:
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185