Created
March 5, 2012 16:16
-
-
Save jdaigle/1979064 to your computer and use it in GitHub Desktop.
find types implementing generic interface
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
| private readonly static Type messageHandlerOpenGenericType = typeof(IMessageHandler<>); | |
| public static IEnumerable<Type> WhereMessageHandlerType(this IEnumerable<Type> types) { | |
| return types.Where(x => x.IsClass && | |
| !x.IsAbstract && | |
| x.GetInterfaces().Any(i => i.IsGenericType && | |
| i.GetGenericTypeDefinition() == messageHandlerOpenGenericType)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment