I need to append new method to the existing event of a static class.
This is my 'cat' static class and cant change it because it it 3rd party. I need to add new method to trigger in the same event myEvent
. This question shows how to do it for non static class. But I'm not sure how to do for static class. Someone there to help?
public static class Cat
{
internal static event EventHandler myEvent;
public static init()
{
....
....
}
}
class Dog
{
public static void init()
{
EventInfo eventInfo = typeof(Cat).GetEvent("myEvent");
if (eventInfo != null)
{
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, , newMethod); // I'm stuck here
eventInfo.AddEventHandler(, handler); // I'm stuck here
}
}
static void newMethod()
{
}
}
If the myEvent
is public I can do Cat.myEvent+= new EventHandler(newMethod);
. But unluckily it is internal