July 2015
Intermediate to advanced
1300 pages
87h 27m
English
Attributes are about applications’ metadata. Because of this, you can use reflection (refer to Chapter 44, “Reflection,” for details) to check whether a type recurs to custom attributes and investigate metadata (that is, application information). To accomplish this, you invoke the System.Reflection.MemberInfo.GetCustomAttributes and System.Reflection.Attributes.GetCustomAttributes shared methods. The first one returns all attributes applied to the specified type; the second one returns an array of custom attributes applied to an assembly, a type or its members, and method parameters. The following is the most basic example for retrieving information about attributes applied to members of the Document class: