Skip to content

Adding metadata to your types: Attributes

April 8, 2007

At the recent Toronto Code Camp, I attended a very interesting session, “Building Plug-ins and Inspecting Classes with Reflection”, by Shawn Hayward. In his presention he talked about how developers can utilize reflection to save coding and make programs extensible. He used three cases to drive his presentation, “Dynamic Method Invocation”, “Attributes”, and “Plugins”.

I especially enjoyed the treatment he provided on Attributes. Using attributes, you can “tag” a class or its members with simple fixed arbitrary data. The attributes are manifested in your assemblies as metadata that is ignored by the .Net framework and to be utilized, you must do your own processing. To read the attribute values you must use reflection. Examples of attributes can be foudn throughout the .Net framework: web services, xml serialization, object serialization, and custom tool support.


From → .Net

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: