Autofac composite pattern
I haven't implemented this or even thought it through fully, but the best syntax I could achieve is:
builder
.RegisterComposite<IService>((c, elements) => new CompositeService(elements))
.WithElementsNamed("impl");
The elements
parameter to the registration function would be of type IEnumerable<IService>
and encapsulate the c.Resolve<IEnumerable<IService>>("impl")
.
Now how to write it...