Simple Extension Points

Autofac provides activation events to let you know when components are being activated or released, allowing for a lot of customization with little code.

var builder = new ContainerBuilder();
// Once a listener has been fully constructed and is
// ready to be used, automatically start listening.
builder.RegisterType<Listener>()
.As<IListener>()
.OnActivated(e => e.Instance.StartListening());
// When a processor is being constructed but before
// it's ready to be used, call an initialization method.
builder.RegisterType<Processor>()
.OnActivating(e => e.Instance.Initialize());
var container = builder.Build();