Created
July 16, 2009 04:13
-
-
Save aaronjensen/148185 to your computer and use it in GitHub Desktop.
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
private static IEnumerable<Type> GetTypesInDirectoryWithExtension(string path, string extension) | |
{ | |
foreach (FileInfo file in new DirectoryInfo(path).GetFiles(extension, SearchOption.AllDirectories)) | |
{ | |
Type[] types = null; | |
try | |
{ | |
Assembly a = Assembly.LoadFrom(file.FullName); | |
types = a.GetTypes(); | |
} | |
catch (ReflectionTypeLoadException err) | |
{ | |
// Suggest cleaning bin directory | |
foreach (var loaderException in err.LoaderExceptions) | |
{ | |
// log loaderException | |
} | |
throw; | |
} | |
foreach (Type t in types) | |
yield return t; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment