Does an abstract class work with StructureMap like an interface does?

abstract-class, dependency-injection, interface, ioc-container, structuremap

Solution

Yes, abstract classes work exactly the same way as interfaces.

If WorkerBase is an abstract class, and RealWorker is an implementation, then:

var container = new Container(x => x.For<WorkerBase>().Use<RealWorker>());
var worker = container.GetInstance<WorkerBase>();

Problem

I am a big fan of StructureMap and use it in just about everything I do. I have only ever used it with interfaces though. I was wondering if anyone had any experience using with abstract classes? or...does it not support that type of wiring? If you got this to work can you post an example? Thanks!

Original source