I had some trouble getting
Structure Map to load concrete instances of an abstract class housed in separate assemblies.
Here's what I wanted, where Core, PersonBase, Bob, and Betty are each separate assemblies:
I expected this to work with:
ObjectFactory.Configure(x => x.Scan (
scan =>
{
scan.AssembliesFromPath(Environment.CurrentDirectory);
scan.WithDefaultConventions(); //doesn't do it
}
));
What I needed was a custom scanner:
public class MyScanner : ITypeScanner {
public void Process(Type type, PluginGraph graph) {
if(type.BaseType == null) return;
if(type.BaseType.Equals(typeof(PersonBase))) {
graph.Configure(x =>
x.ForRequestedType()
.TheDefault.Is.OfConcreteType(type));
}
}
}
The full writeup is on
Stack Overflow.