Skip to content

Instantly share code, notes, and snippets.

@421p
Last active September 3, 2016 11:35
Show Gist options
  • Save 421p/2f62b763bb7d0f9cebc7a8bcd9510dcc to your computer and use it in GitHub Desktop.
Save 421p/2f62b763bb7d0f9cebc7a8bcd9510dcc to your computer and use it in GitHub Desktop.
Find all types that implements interface IController
private static IEnumerable<Type> LoadControllers()
{
return typeof (IController).GetTypeInfo().Assembly.DefinedTypes
.Where(type => type.ImplementedInterfaces.Any(x => x == typeof(IController)));
}
private static IEnumerable<Type> FindTypesImplements<T>()
{
return typeof (T).GetTypeInfo().Assembly.DefinedTypes
.Where(type => type.ImplementedInterfaces.Any(x => x == typeof(T)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment