Files
OurUmbraco/uForum/EventExtensions.cs
T
ploug@umbraco.dk 56a2ace7d2 Initial commit of our WIP
This is very likely break the dev site
2015-01-26 13:13:06 +01:00

29 lines
849 B
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace uForum
{
public static class EventExtensions
{
public static void Raise<T>(this EventHandler<T> handler, object sender, T args) where T : EventArgs
{
if (handler != null) handler(sender, args);
}
//returns true if there is no handler or if the handler doesnt set Cancel to true
public static bool RaiseAndContinue<T>(this EventHandler<T> handler, object sender, T args) where T : CancelEventArgs
{
if (handler == null)
return true;
handler(sender, args);
return (args.Cancel != true);
}
}
}