views:

61

answers:

1

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!

+1  A: 

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>();
Joshua Flanagan