Skip to content

Instantly share code, notes, and snippets.

@manicolosi
Created February 2, 2009 02:30
Show Gist options
  • Save manicolosi/56746 to your computer and use it in GitHub Desktop.
Save manicolosi/56746 to your computer and use it in GitHub Desktop.
using System;
public delegate bool Predicate<T, U> (T arg1, U arg2);
public static class EventHelper
{
public static EventHandler<T> Filter<T> (Predicate<object, T> predicate,
EventHandler<T> handler) where T: EventArgs
{
EventHandler<T> filtered = (object sender, T args) => {
if (predicate (sender, args)) {
handler (sender, args);
}
};
return filtered;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment