Kanda Foundation 0.2.0
Loading...
Searching...
No Matches
ServiceContainer Class Reference

More...

+ Inheritance diagram for ServiceContainer:

Public Member Functions

void Register< T > (T instance, bool overwriteExisting=false)
 Registers an instance of a service by type. This service will be resolved like a singleton with Get<T> and GetAsync<T>.
Parameters
instanceThe service instance to register.
overwriteExistingIf true, this will override any previously registered instance for this type.
Template Parameters
TThe type of service to register.

 
Get< T > ()
 Gets a service by type.
Template Parameters
TThe type of service to get.
Returns
An instance of the service.
Exceptions
ServiceResolutionException<T>Thrown if no instances or factories have been registered for this type.

 
async Task< T > GetAsync< T > (AsyncObjectResolutionOptions options=null)
 Gets a service by type.
Template Parameters
TThe type of service to get.
Returns
An instance of the service.
Exceptions
ServiceResolutionException<T>Thrown if no instances or factories have been registered for this type.

 

Detailed Description

Member Function Documentation

◆ Get< T >()

T Get< T > ( )
inline

Gets a service by type.

Template Parameters
TThe type of service to get.
Returns
An instance of the service.
Exceptions
ServiceResolutionException<T>Thrown if no instances or factories have been registered for this type.

Implements IServiceContainer.

◆ GetAsync< T >()

async Task< T > GetAsync< T > ( AsyncObjectResolutionOptions options = null)
inline

Gets a service by type.

Template Parameters
TThe type of service to get.
Returns
An instance of the service.
Exceptions
ServiceResolutionException<T>Thrown if no instances or factories have been registered for this type.

Implements IServiceContainer.

◆ Register< T >()

void Register< T > ( T instance,
bool overwriteExisting = false )
inline

Registers an instance of a service by type. This service will be resolved like a singleton with Get<T> and GetAsync<T>.

Parameters
instanceThe service instance to register.
overwriteExistingIf true, this will override any previously registered instance for this type.
Template Parameters
TThe type of service to register.

Implements IServiceContainer.


The documentation for this class was generated from the following file: