To make it easy to add a generic single parameter argument
for an application, the following event argument was created.
Listing 1
namespace Nucleo.EventArguments
{
public class DataEventArgs < T > : EventArgs
{
private T _data;
public T Data
{
get
{
return _data;
}
}
public DataEventArgs(T data)
{
_data = data;
}
}
public delegate void DataEventHandler < T > (object sender, DataEventArgs < T
> e);
}
This event argument makes it simplistic to expose a single
strongly-typed event argument property in an application. Below are some of
the examples of the consumption of the delegate.
Listing 2
public static event DataEventHandler<Document> DocumentClosed;
public static event DataEventHandler<Document> DocumentCreated;
public static event DataEventHandler<Document> DocumentSelected;
These delegates are defined in a static class and any class
that references these events will have a DataEventArgs object that has a
Document type.