Introduction
This articles discusses how to add event handlers by defining custom attributes on the event definitions and their handler methods.
Background
By using EventDistirbutor
, you don't need to have references between the event and its handler method class.
Using the Code
Publish your event:
[PublishEvent("OnOver")]
public event EventHandler OnOver;
Subscribe to the event:
This must be public
!
[SubscriberEvent("OnOver")]
public void OnOver(object sender, EventArgs e)
{
Console.WriteLine("OnOver From Class A");
}
History
- 18th December, 2007: Initial post