[Mono-list] Method Attributes
Andreas Nahr
ClassDevelopment@A-SoftTech.com
Mon, 18 Aug 2003 13:10:57 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C3658A.29D716C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
On Sat, 2003-08-16 at 15:17, Hamza Karamali wrote:
> Hi,
>=20
> If I attach a custom attribute called "myAttribute" to a certain =
method,
> how can I check in Mono (while the method is being compiled) whether a
> method has this attribute? Is there a function that will search the
> metadata for the attribute if I pass it the name of the attribute? If
> not, how would I go about doing this?
>=20
Just call:
TypeDescriptor.GetAttributes(TheObjectThatShouldBeTested)
and check for the attribute in the result AttributeCollection
(Please note that this function may not be completed 100% in Mono right =
now)
Andreas
------=_NextPart_000_000A_01C3658A.29D716C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial>On Sat, 2003-08-16 at 15:17, Hamza Karamali=20
wrote:<BR>><I> Hi,<BR></I>><I> <BR></I>><I> If I attach a =
custom=20
attribute called "myAttribute" to a certain method,<BR></I>><I> how =
can I=20
check in Mono (while the method is being compiled) whether =
a<BR></I>><I>=20
method has this attribute? Is there a function that will search=20
the<BR></I>><I> metadata for the attribute if I pass it the name of =
the=20
attribute? If<BR></I>><I> not, how would I go about doing=20
this?<BR></I>><I> <BR></I></FONT></DIV>
<DIV><FONT face=3DArial>Just call:</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial><FONT=20
size=3D2>TypeDescriptor.GetAttributes(TheObjectThatShouldBeTested)</FONT>=
</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial><FONT size=3D2>and check for the attribute in =
the result=20
AttributeCollection</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>(Please note that this function =
may not be=20
completed 100% in Mono right now)</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial><FONT =
size=3D2>Andreas</FONT></DIV></FONT></BODY></HTML>
------=_NextPart_000_000A_01C3658A.29D716C0--