Autofac, starting components

Some of my components need to be started after all of them have been created. This is quite easy to solve with Autofac. The components simply implement this interface:

    public interface IStartable
    {
        void Start();
    }

Then all I need to do is to invoke the start method:

Components.Resolve<IEnumerable<IStartable>>().Each(c => c.Start());

Note that I resolve IEnumerable and not simply IStartable. That’s the way to tell Autofac that you expect to get all components that have been registered with the same interface.