Skip to content

Overriding Event Implementation

Jon Wagner edited this page Mar 4, 2013 · 1 revision

Overriding Event Implementation

In some cases, you may not want to use the standard implementation that ESP uses for its events. Perhaps you have a lot of data that you need to write to the event stream. If you are using an EventSource class, you can choose to implement the method yourself rather than having ESP implement the method. (This does not work for interface implementations.)

public abstract class CalculatorEventSource : EventSource
{
	public abstract void Clear();

	public void Add(int x, int y)
	{
		WriteEvent(3, x, y);
	}

	public static CalculatorEventSource Log = EventSourceImplementer.GetEventSourceAs<CalculatorEventSource>();
}

In the example above, ESP will automatically implement the abstract Clear method, but it will call your Add method directly to write the event. You are responsible for all of the attributes and other code that you write.