mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
44 lines
1.6 KiB
using System;
|
|
|
|
namespace Abp.Extensions
|
|
{
|
|
/// <summary>
|
|
/// Extension methods for <see cref="EventHandler"/>.
|
|
/// </summary>
|
|
public static class EventHandlerExtensions
|
|
{
|
|
/// <summary>
|
|
/// Raises given event safely with given arguments.
|
|
/// </summary>
|
|
/// <param name="eventHandler">The event handler</param>
|
|
/// <param name="sender">Source of the event</param>
|
|
public static void InvokeSafely(this EventHandler eventHandler, object sender)
|
|
{
|
|
eventHandler.InvokeSafely(sender, EventArgs.Empty);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raises given event safely with given arguments.
|
|
/// </summary>
|
|
/// <param name="eventHandler">The event handler</param>
|
|
/// <param name="sender">Source of the event</param>
|
|
/// <param name="e">Event argument</param>
|
|
public static void InvokeSafely(this EventHandler eventHandler, object sender, EventArgs e)
|
|
{
|
|
eventHandler?.Invoke(sender, e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raises given event safely with given arguments.
|
|
/// </summary>
|
|
/// <typeparam name="TEventArgs">Type of the <see cref="EventArgs"/></typeparam>
|
|
/// <param name="eventHandler">The event handler</param>
|
|
/// <param name="sender">Source of the event</param>
|
|
/// <param name="e">Event argument</param>
|
|
public static void InvokeSafely<TEventArgs>(this EventHandler<TEventArgs> eventHandler, object sender, TEventArgs e)
|
|
where TEventArgs : EventArgs
|
|
{
|
|
eventHandler?.Invoke(sender, e);
|
|
}
|
|
}
|
|
}
|