facet classafIoc::Inject
sys::Obj afIoc::Inject : sys::Facet
Use in classes to denote a field that should be dependency injected.
It is the intention that @Inject be (re)used as a general purpose facet by many dependency providers in IoC and by custom libraries. Hence support for the attributes id, type, and optional is entirely dependent on the individual dependency provider.
Core IoC dependency providers use the @Inject facet to:
- inject IoC services
- inject Log instances
- mark ctors to use for autobuilding / service creation.
- id
const Str? id := nullWhen injecting services,
iddenotes the qualified ID of the service to inject. (optional)When injecting
Loginstances,iddenotes the log name. (optional)- optional
const Bool optional := falseIf
trueand the dependency / service does not exist then injection should fail silently without causing an Err.- type
const Type? type := nullWhen injecting services,
typeis used to look up the service - which may be different (or more specific) than the field type. (optional)