using System;
namespace Wayne.Lib
{
///
/// Contains extension methods for firing events.
///
public static class Events
{
///
/// Fires the event if it is not null.
///
///
///
///
///
public static void Fire(this EventHandler eventHandler, object sender, TEventArgs eventArgs)
where TEventArgs : EventArgs
{
if (eventHandler != null)
{
eventHandler(sender, eventArgs);
}
}
///
/// Fires the event if it is not null.
///
///
///
///
public static void Fire(this EventHandler eventHandler, object sender, EventArgs eventArgs)
{
if (eventHandler != null)
{
eventHandler(sender, eventArgs);
}
}
///
/// Fires the action if not null
///
///
public static void Fire(this Action action)
{
if (action != null)
{
action();
}
}
///
/// Fires the action if not null
///
///
///
public static void Fire(this Action action, T t)
{
if (action != null)
{
action(t);
}
}
///
/// Fires the action if not null
///
///
///
///
public static void Fire(this Action action, T1 t1, T2 t2)
{
if (action != null)
{
action(t1, t2);
}
}
///
/// Fires the action if not null
///
///
///
///
///
public static void Fire(this Action action, T1 t1, T2 t2, T3 t3)
{
if (action != null)
{
action(t1, t2, t3);
}
}
}
}