Property/Field Injection
Dependencies can be injected into properties or fields as well. To do so, annotate each property or field that represents a dependency with [Inject]
.
class ClassA{ [Inject] IServiceA serviceA { get; set; } [Inject] IServiceB serviceB;
public ClassA() { }}
Injection via properties or fields is a helpful alternative to method injection.