I think Tuple-style EventArgs are useful. Just like Tuple's, they can be misused, but it seems my laziness is stronger than my sense of caution. I implemented the following:
public static class TupleEventArgs
{
static public TupleEventArgs<T1> Create<T1>(T1 item1)
{
return new TupleEventArgs<T1>(item1);
}
static public TupleEventArgs<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
{
return new TupleEventArgs<T1, T2>(item1, item2);
}
static public TupleEventArgs<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
{
return new TupleEventArgs<T1, T2, T3>(item1, item2, item3);
}
}
public class TupleEventArgs<T1> : EventArgs
{
public T1 Item1;
public TupleEventArgs(T1 item1)
{
Item1 = item1;
}
}
public class TupleEventArgs<T1, T2> : EventArgs
{
public T1 Item1;
public T2 Item2;
public TupleEventArgs(T1 item1, T2 item2)
{
Item1 = item1;
Item2 = item2;
}
}
public class TupleEventArgs<T1, T2, T3> : EventArgs
{
public T1 Item1;
public T2 Item2;
public T3 Item3;
public TupleEventArgs(T1 item1, T2 item2, T3 item3)
{
Item1 = item1;
Item2 = item2;
Item3 = item3;
}
}
Can be used as follows (when used with an event raiser extension)
public event EventHandler<TupleEventArgs<string,string,string>> NewEvent;
NewEvent.Raise(this, TupleEventArgs.Create("1", "2", "3"));