开发者

StructureMap scan assemblies from every folder within a given directory

开发者 https://www.devze.com 2023-01-24 18:39 出处:网络
I have a mvc project and in the bin folder i have an plugin folder and it look like this /bin/ 开发者_开发技巧 /plugin

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消