facet classafIoc::Inject

sys::Obj
  afIoc::Inject : sys::Facet

@Serializable

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

Source

const Bool autobuild := false

If true then a new instance of the dependency / service is created via Registry.autobuild().

Can be used to new up classes that have not been defined as a service.

Defaults to false.

optional

Source

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

Source

const Str? serviceId

Specifies the (qualified) id of the service to inject.

Use when a service mixin has multiple implementations.