Calling Method of a Class within StructureMap Registry Configuration
I can't help but think there is a better way to do this than my current code within my StructureMap Registry.
开发者_JS百科 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)
Yes, you can do this:
For<IScheduler>().Use(c => c.GetInstance<ISchedulerFactory>().GetScheduler());
精彩评论