O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom Attributes

All the reflection information we’ve seen so far is based on metadata that’s well known to the runtime. One typical example of such metadata includes the visibility of types and members. Early on in the design of the CLR, it was clear that an extensible metadata system would be a true added value to the new runtime. This ultimately resulted in the creation of custom attributes that allow developers to define their own pieces of metadata that can be tagged onto assemblies, types, and their members.

You’ve seen a couple of attributes earlier in this chapter when we were discussing MEF. In the following code fragment, Export is an attribute:

[Export(typeof(ICalculation))]public class Pythagoras : ICalculation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required