Does an abstract class work with StructureMap as an interface?

I am a big fan of StructureMap and use it in almost everything I do. However, I used it only with interfaces. I was wondering if anyone has any experience using abstract classes? or ... does this type of wiring support? If you got this to work, can you send an example?

Thanks!

+4
source share
1 answer

Yes, abstract classes work just like 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>(); 
+7
source

All Articles