views:

17

answers:

1

I can't help but think there is a better way to do this than my current code within my StructureMap Registry.

  For<ISchedulerFactory>().Use(() => new StdSchedulerFactory());
  For<IScheduler>().Use(() => new StdSchedulerFactory().GetScheduler());

Is there a way to have it use the previous registered type and call the method from that? (GetScheduler() is on ISchedulerFactory interface)

+1  A: 

Yes, you can do this:

For<IScheduler>().Use(c => c.GetInstance<ISchedulerFactory>().GetScheduler());
Robin Clowers
Works great! I knew there had to be a better way. Thanks for the help!
phreak3eb