Created
February 2, 2009 02:30
-
-
Save manicolosi/56746 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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