So I have an EventHandler:
public event EventHandler<CustomEventArgs> Confirmed;
protected void RaiseConfirmed()
{
Confirmed?.Invoke(this, new CustomEventArgs(Color.red));
}
And I have a couple of event listeners in different classes, such as.
public void SetColor(object sender, CustomEventArgs e)
{
//do something with e.Color
}
But that's not exactly what I want.
Is it possible to raise the event, but send different EventArgs to the different listeners?
So when the Confirm button is clicked, and the Confirmed event is fired, I want to set one listener to Color red, the other to Color blue, and yet another listener to Color green. And perhaps I have yet another listener that does not take a color, but a bool value.
So essentially, the sender does not really know about the argument. The argument is injected before the receiver receives it.
Does that make sense? Should I implement my own event handling to support different arguments per listener?