Created
November 25, 2014 14:35
-
-
Save johnbabb/f44f5f404ad421d5f72e to your computer and use it in GitHub Desktop.
CustomAssemblyResolver
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
public class CustomAssemblyResolver : DefaultAssembliesResolver | |
{ | |
private Assembly[] plugins = ( | |
from file in Directory.GetFiles( | |
AssemblyDirectory, "*.dll", | |
SearchOption.AllDirectories) | |
let assembly = Assembly.LoadFile(file) | |
select assembly) | |
.ToArray(); | |
public static string AssemblyDirectory | |
{ | |
get | |
{ | |
string codeBase = Assembly.GetExecutingAssembly().CodeBase; | |
UriBuilder uri = new UriBuilder(codeBase); | |
string path = Uri.UnescapeDataString(uri.Path); | |
return Path.GetDirectoryName(path); | |
} | |
} | |
public override ICollection<Assembly> GetAssemblies() | |
{ | |
return base.GetAssemblies() | |
.Union(this.plugins).ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment