facet classafIoc::Inject
sys::Obj afIoc::Inject : sys::Facet
Use in services to inject dependencies and services.
- Place on a field to mark it for field injection
- Place on a ctor to mark it for use by autobuilding / service creation
- autobuild
const Bool autobuild := false
If
true
then a new instance of the dependency / service is created viaRegistry.autobuild()
.Can be used to new up classes that have not been defined as a service.
Defaults to
false
.- optional
const Bool optional := false
If
true
and the dependency / service does not exist then injection fails silently without causing an Err.Useful when injecting services from (optional) 3rd party libraries.
Defaults to
false
.- serviceId
const Str? serviceId
Specifies the (qualified) id of the service to inject.
Use when a service mixin has multiple implementations.