Register Collection
VContainer supports automatically resolving particular types implicitly to support special relationships.
Duplicate registered interfaces can be resolved together with IEnumerable<T>
or IReadOnlyList<T>
.
builder.Register<IDisposable, A>(Lifetime.Scoped);
builder.Register<IDisposable, B>(Lifetime.Scoped);
class ClassA
{
public ClassA(IEnumerable<IDisposable> disposables) { /* ... */ }
}
OR
class ClassA
{
public ClassA(IReadOnlyList<IDisposable> disposables) { /* ... */ }
}
note
This is mainly used by internal functions such as the ITickable
marker, etc.