Container

A dependency injection container.

Providers are registered with a TypeInfo and an optional name. Values can then be resolved using the TypeInfo and name.

Members

Functions

addProvider
void addProvider(TypeInfo type, Provider provider)
void addProvider(TypeInfo type, string name, Provider provider)

Register a Provider for it's TypeInfo. A name can also be provided to disambiguate when multiple providers are needed

factory
void factory(Flag!"asSingleton" asSingleton)
void factory(string name, Flag!"asSingleton" asSingleton)
void factory(F func, Flag!"asSingleton" asSingleton)
void factory(string name, F func, Flag!"asSingleton" asSingleton)

Register a factory function for a type.

provider
void provider(Provider provider)
void provider(string name, Provider provider)

Register a provider using the type returned by provider.providedType.

register
void register(Flag!"asSingleton" asSingleton)
void register(string name, Flag!"asSingleton" asSingleton)

Register a Class.

value
void value(string name, T value)
void value(T value)

Register a single value.

Inherited Members

From Resolver

withResolvedPtr
void withResolvedPtr(TypeInfo info, void delegate(void*) dg)
void withResolvedPtr(TypeInfo info, string name, void delegate(void*) dg)

Resolve an instance of the type of TypeInfo, and execute a delegate with a pointer to that instance (as a void*).

resolve
T resolve()
T resolve(string name)

Resolve an instance of type T. If name is provided use that to disambiguate between multiple providers.

canResolve
bool canResolve(TypeInfo type)
bool canResolve(TypeInfo type, string name)

Check if the resolver can resolve a type (possibly with a name).

Meta