I implemented this using reflection and extension methods so that I can just invoke (in this case) a LinkLabel click event by just calling:
var link = new LinkLabel()'
link.Text = "Some link";
link.click();
the click() method is an C# extension method:
public static void click(this LinkLabel linkLabel)
{
var e = new LinkLabelLinkClickedEventArgs((LinkLabel.Link)(linkLabel.prop("FocusLink")));
linkLabel.invoke("OnLinkClicked", e);
}
which uses another extension methods to:
- get a private property from the LinkLabel (needed to create the LinkLabelLinkClickedEventArgs object)
- invoke the OnLinkClicked method (which will fire the event