mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-14 20:25:01 +00:00
Created S# .sln and moved project to src folder
This commit is contained in:
35
ICD.Common/Utils/Extensions/EventHandlerExtensions.cs
Normal file
35
ICD.Common/Utils/Extensions/EventHandlerExtensions.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace ICD.Common.Utils.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for EventHandlers.
|
||||
/// </summary>
|
||||
public static class EventHandlerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Raises the event safely. Simply skips if the handler is null.
|
||||
/// </summary>
|
||||
/// <param name="extends"></param>
|
||||
/// <param name="sender"></param>
|
||||
public static void Raise(this EventHandler extends, object sender)
|
||||
{
|
||||
if (extends != null)
|
||||
extends(sender, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the event safely. Simply skips if the handler is null.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="extends"></param>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
public static void Raise<T>(this EventHandler<T> extends, object sender, T args)
|
||||
where T : EventArgs
|
||||
{
|
||||
if (extends != null)
|
||||
extends(sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user