The question is not really related to MVC. You don't "invoke" an attribute — there is no suck think. The attributes are "attributed" the the assemblies, modules, types, members and parameters as additional meta-data. When you execute any portion of your run time, they are already there. All you can do it to examine if the declarations of the programming entities mentioned above have some type of attributes; and if an attribute of certain type is found, you can read its properties. This can be done using some methods named
GetCustomAttributes
:
http://msdn.microsoft.com/en-us/library/system.attribute.getcustomattributes.aspx[
^].
There are more methods, but I don't want to show them as they comes with most Reflection types:
Assembly
,
Type
,
MethodInfo
,
ConstructorInfo
,
MemberInfo
,
FieldInfo
,
PropertyInfo
,
ParameterInfo
and the like. You would be better off finding appropriate attribute-related methods by yourself, as you need them.
—SA