Last active
September 3, 2016 11:35
-
-
Save 421p/2f62b763bb7d0f9cebc7a8bcd9510dcc to your computer and use it in GitHub Desktop.
Find all types that implements interface IController
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 static IEnumerable<Type> LoadControllers() | |
{ | |
return typeof (IController).GetTypeInfo().Assembly.DefinedTypes | |
.Where(type => type.ImplementedInterfaces.Any(x => x == typeof(IController))); | |
} |
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 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