check point
This commit is contained in:
43
framework/Inspectron.Settings/Event.cs
Normal file
43
framework/Inspectron.Settings/Event.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Inspectron.Settings
|
||||
{
|
||||
public static class Event
|
||||
{
|
||||
public static void Raise(this EventHandler handler, object sender, EventArgs e)
|
||||
{
|
||||
if (handler != null) handler(sender, e);
|
||||
}
|
||||
|
||||
public static void Raise<T>(this EventHandler<T> handler, object sender, T e) where T : EventArgs
|
||||
{
|
||||
if (handler != null) handler(sender, e);
|
||||
}
|
||||
|
||||
public static bool RaiseCancellable(this CancelEventHandler handler, object sender, CancelEventArgs e)
|
||||
{
|
||||
if (handler != null)
|
||||
foreach (CancelEventHandler h in handler.GetInvocationList())
|
||||
{
|
||||
h(sender, e);
|
||||
if (e.Cancel) break;
|
||||
}
|
||||
|
||||
return e.Cancel;
|
||||
}
|
||||
|
||||
public static bool RaiseCancellable<T>(this EventHandler<T> handler, object sender, T e)
|
||||
where T : CancelEventArgs
|
||||
{
|
||||
if (handler != null)
|
||||
foreach (EventHandler<T> h in handler.GetInvocationList())
|
||||
{
|
||||
h(sender, e);
|
||||
if (e.Cancel) break;
|
||||
}
|
||||
|
||||
return e.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user