Created
January 5, 2013 22:14
-
-
Save haacked/4463987 to your computer and use it in GitHub Desktop.
Method to return all loadable types in an assembly. See [this blog post](http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx) for details.
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
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly) | |
{ | |
if (assembly == null) throw new ArgumentNullException("assembly"); | |
try | |
{ | |
return assembly.GetTypes(); | |
} | |
catch (ReflectionTypeLoadException e) | |
{ | |
return e.Types.Where(t => t != null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment