C# delegates

Hello. I’m working on event system. And I a little bit stuck with this issue.

I have delegate

public delegate void EventHandlerFunction();

and I have function like

public void addEventListner(string eventName, EventHandlerFunction handler)

I calling this function form “ExampleListner

btn.addEventListner(BaseEvent.CLICK, onButtonClick);

So, now the question.

How can I in addEventListner function get

  1. name of delegate function witch is “onButtonClick” in this example.
  2. owner class, ExampleListner in this example.

Thx for help.

Try this (not tested, don’t know if it would work):

handler.Method.Name

Try this (same warning from above):

handler.Target.GetType().Name

But unless you’re going to use that information for logging or diagnostics, I would try to rework my code to NOT rely on those two string values.

shaderop, thx for replay. This does not working, handler simply does not have parameters like

handler.Method.Name

But Func<Void> handler does. So now I’m using it. Thx for help any way.

And yes, you are write I collecting this information for logging purposes only. And this part of code will work only in editor.