Skip to content

Instantly share code, notes, and snippets.

@jdaigle
Created March 5, 2012 16:16
Show Gist options
  • Select an option

  • Save jdaigle/1979064 to your computer and use it in GitHub Desktop.

Select an option

Save jdaigle/1979064 to your computer and use it in GitHub Desktop.
find types implementing generic interface
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