Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Structuremap DefaultConventionScanner find non-public classes

Tags:

structuremap

I have just started using StructureMap, having previously worked with Spring.Net. I love the DefaultConventionScanner and the ability to scan assemblies and use convention over configuration to find classes. But there seems to be a limitation that the classes that implement the interfaces must be public, whereas we like to keep out interfaces public and our implementations internal to an assembly.

Is there a way to ask the DefaultConventionScanner to find internal classes as well?

like image 806
Colin Desmond Avatar asked Sep 29 '09 12:09

Colin Desmond


Video Answer


1 Answers

No, and in fact the limitation that classes should be public applies to all of StructureMap - not just the convention scanners. You can register internal types manually with StructureMap if you make use of the InternalsVisibleTo attribute, but it is not well-supported or documented. You will not be able to make an ITypeScanner (like DefaultConventionScanner) that registers internal types because the AssemblyScanner only exposes exported types.

like image 199
Joshua Flanagan Avatar answered Sep 22 '22 05:09

Joshua Flanagan