StructureMap scan assemblies from every folder within a given directory
I have a mvc project and in the bin folder i have an plugin folder and it look like this
/bin/
开发者_开发技巧 /plugin
/plugin1
/plugin2
and i what to scan with structure map every assembly in plugin folder i've try with AssembliesFromPath but is not loading any assembly.
How can i load all the assembly from every directory within plugin folder ?
StructureMap doesn't recursively search a path, so you just need to call AssembliesFromPath on each of the paths that contain your plugins (ex: bin\plugin\plugin1, bin\plugin\plugin2).
Of course you don't need to hardcode in all of the subdirectories. StructureMap registration code is c#, which means you can use the language constructs. Call Directory.GetDirectories() on your bin\plugin to get the list of subdirectories, and then just loop over them within your Scan() clause to call AssembliesFromPath on each subdirectory.
精彩评论