I'd like to be able to implement this in my windsor castle container set up:
"For all types that implement IStartable in the current assembly register them and run the Start method for them."
Similar to what you can do using Autofac for things like registering Automapper mappings. eg
public class MyBlahViewModelMapper : IStartable
{
public void Start()
{
Mapper.CreateMap<MyBlahEntity, MyBlahViewModel>();
}
}
Autofac does it automagically.... I'm thinking Windsor can't help me here?
Windsor has its own
IStartable
interface. If you want Windsor to register your objects and create/run them immediately after that you'd use Startable Facility for that.To clarify, there are two concepts here:
IStartable
interface, which providesStart
andStop
methods. This is a lifecycle interfaces that provide lifecycle callbacks:Start
being called right after a component instance gets created (after the constructor runs)Startable Facility, which forces your
IStartable
components to be instantiated and started immediately after installers have ran.Here's what the code would look like:
If you're on Windsor 3.3 or later you can also manually trigger the startables to start (which is useful if you need to do some extra setup for them)