facet classafIoc::Inject
sys::Obj afIoc::Inject : sys::Facet
Use in services to inject other services and dependencies.
It is the intention that @Inject be (re)used a general purpose facet for many Dependency Providers, both within and outside the IoC library itself.
With that in mind, support for the facet attributes id, type and optional is entirely dependent on the individual dependency providers.
Within IoC the @Inject facet is used to:
- inject IoC services,
- inject
Loginstances, - inject
LocalRef,LocalListandLocalMapinstances, - mark ctors to use for autobuilding / service creation.
- id
const Str? idUsage within IoC is optional:
- Service injection: the (qualified) id of the service to inject (use when the same mixin has multiple implementations)
Loginjection: the name of the log to injectLocalRefinjection: the name used to store the local ref.
- optional
const Bool optional := falseIf
trueand the dependency / service does not exist then injection should fail silently without causing an Err.Within IoC
optionalis only used when injecting services. Useful when injecting services from (optional) 3rd party libraries.Defaults to
false.- type
const Type? typeUsage within IoC is optional:
LocalRefinjection: the List / Map type.