Last active
August 29, 2015 14:16
-
-
Save restlessmedia/1ac3630dd548f660344f to your computer and use it in GitHub Desktop.
GetLoadedTypes (extension)
This file contains 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
/// <summary> | |
/// Gets the loaded types for this Assembly and skips if any types cannot be loaded when ReflectionTypeLoadException is thrown. | |
/// </summary> | |
/// <param name="assembly"></param> | |
/// <returns></returns> | |
public static Type[] GetLoadedTypes(this Assembly assembly) | |
{ | |
try | |
{ | |
return assembly.GetTypes(); | |
} | |
catch (ReflectionTypeLoadException e) | |
{ | |
return e.Types.Where(t => t != null).ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment