[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

How to get the full signature of a delegate?

Evan Camilleri

5/18/2007 10:28:00 AM

I need to get the full signature of a delagate in a string. Is this
possible?

In a control I have:

public delegate void Button_Click(object sender, EventArgs e);

public event Button_Click click;



then I have:



private void GetControlEvents(Control cControl)

{

EventInfo[] eventlist = cControl.GetType().GetEvents();



foreach(EventInfo eventlst in eventlist)

{

string st = eventlst.EventHandlerType.Name

}

}



In the above, variable st will have "Button_Click"



----------------------------

WHAT I NEED

----------------------------



I need to get in a string "void Button_Click(object sender, EventArgs e)"





Evan Camilleri


2 Answers

Kevin Spencer

5/18/2007 10:58:00 AM

0

The following MSDN article may be of help:

http://msdn2.microsoft.com/en-us/library/ms2...

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.mi...

"news.microsoft.com" <evan@holisticrd.com.nospam> wrote in message
news:uGwtmcTmHHA.3264@TK2MSFTNGP04.phx.gbl...
>I need to get the full signature of a delagate in a string. Is this
>possible?
>
> In a control I have:
>
> public delegate void Button_Click(object sender, EventArgs e);
>
> public event Button_Click click;
>
>
>
> then I have:
>
>
>
> private void GetControlEvents(Control cControl)
>
> {
>
> EventInfo[] eventlist = cControl.GetType().GetEvents();
>
>
>
> foreach(EventInfo eventlst in eventlist)
>
> {
>
> string st = eventlst.EventHandlerType.Name
>
> }
>
> }
>
>
>
> In the above, variable st will have "Button_Click"
>
>
>
> ----------------------------
>
> WHAT I NEED
>
> ----------------------------
>
>
>
> I need to get in a string "void Button_Click(object sender, EventArgs e)"
>
>
>
>
>
> Evan Camilleri
>
>


Jon Skeet

5/18/2007 11:03:00 AM

0

On May 18, 11:27 am, "news.microsoft.com" <e...@holisticrd.com.nospam>
wrote:

<snip>

> I need to get in a string "void Button_Click(object sender, EventArgs e)"

As shown in the docs for EventInfo.EventHandlerType, if you get the
Invoke method of the delegate type, you can retrieve the parameter
types and return type from that.

Jon