DependencyContainer.register

Register a dependency by super type.

A dependency registered by super type can only be resolved by super type. A qualifier is typically used to resolve dependencies registered by super type.

The default registration scope is "single instance" scope.

  1. Registration register(RegistrationOption options)
  2. Registration register(RegistrationOption options)
    class DependencyContainer
    public
    register
    (
    SuperType
    ConcreteType : SuperType
    )
    if (
    !is(ConcreteType == struct)
    )

Examples

Register and resolve by super type

class Cat : Animal { ... }
container.register!(Animal, Cat);

See Also

singleInstance, newInstance, existingInstance, RegistrationOption

Meta