How to identify a delegate ?

253 views
Skip to first unread message

joer

unread,
Dec 2, 2010, 4:56:46 PM12/2/10
to mono-cecil
Delegates seem to be normal Types same as classes.

How do I know that its a delegate ?

Joe

Simon Cropp

unread,
Dec 2, 2010, 5:19:48 PM12/2/10
to mono-...@googlegroups.com
How about this

public static class CecilExtensions
{
public static bool IsDelegate(this TypeDefinition typeDefinition)
{
if (typeDefinition.BaseType == null)
{
return false;
}
return typeDefinition.BaseType.FullName == "System.MulticastDelegate";
}

}

> --
> --
> mono-cecil

Joe Robe

unread,
Dec 2, 2010, 5:38:04 PM12/2/10
to mono-...@googlegroups.com
yeah I figured this out, thanks.

I thought there is an easier way, a flag somewhere which I missed.

Joe

> --
> --
> mono-cecil

--
Kindest regards

Joe Robe
President
RobeSoft Inc.
Phone:+1 954 234 2662
Fax:+1 813 425-9759
EMail:Joe...@RobeSoft.com
Skype:joer00
Yahoo Messenger ONLY(do not send email):joer...@yahoo.com
MSN:Messenger ONLY(do not send email):joer...@hotmail.com
www.RobeSoft.com

Reply all
Reply to author
Forward
0 new messages