In a magical confluence of events, I’m free from all parental and spousal responsibilities today and I’m trying to use the day to write StructureMap docs. Hopefully, this is the first post of several today.
This is the very last (or next to last) feature to make it into the StructureMap 2.5 release that Josh added last week to support an extensibility need that we have at Dovetail. From the documentation:
StructureMap 2.5 has a brand new capability to auto register types in all assemblies in a given folder path. My current project is using this feature for our extensibility mechanism. For customer-specific deployments, we need to add business rules and even all new screens and features to our application that can be discovered at runtime — without changing our core code. Our design calls for all extensions to be created in separate assemblies. On application startup, our system will look for all assemblies in a well known folder and use StructureMap to scan these assemblies for the extensions that will be specified in Registry classes. Our bootstrapping looks like:
Note in the code above that I made an explicit call to "LookForRegistries." Scanning for Registry’s is no longer active by default. This is a breaking change from the 2.4.9 preview release.
You can also filter the assemblies based on a Predicate like this: