There are a few different technologies available to integrate and extend the Visual Studio environment.
Attributes provide one means to extend Visual Studio and are used to integrate custom
server controls into the environment. Before we present a quick overview of the most important
design-time attributes, we provide a short background on attributes.
What??™s an Attribute?
An attribute is essentially a class that contains properties and methods used to modify other
classes, class methods, or class properties. Attribute information is stored with the metadata of
the element and can be retrieved at runtime through reflection.
Attributes can be applied to an entire class or to a specific class method or property. Attribute
classes are defined as public classes. All attributes derive directly or indirectly from the System.
Attribute class, and attribute classes generally end in the word Attribute to enhance readability.
Here is a sample attribute declaration:
public class SampleAttribute : Attribute
{
}
An attribute is declared within brackets just before the element to which it is applied. The
syntax consists of calling a constructor on the attribute. Here is how an attribute is applied to a
class method:
CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN ASP.
Pages:
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154