Beamable SDK
Public Member Functions | Public Attributes | Properties | List of all members
Beamable.Common.Dependencies.DependencyProvider Class Reference
Inheritance diagram for Beamable.Common.Dependencies.DependencyProvider:
Inheritance graph
[legend]
Collaboration diagram for Beamable.Common.Dependencies.DependencyProvider:
Collaboration graph
[legend]

Public Member Functions

 DependencyProvider (DependencyBuilder builder)
 
GetService< T > ()
 Finds an instance of a service given the type parameter. All services are lazily initialized, so its possible that if is the first time the type of service has been requested, this call could allocate a new instance of the service. More...
 
bool CanBuildService< T > ()
 Returns true if the given service is registered in the provider. If you make a call to GetService<T> for a service that doesn't exist, you'll get an exception. More...
 
bool CanBuildService (Type t)
 Returns true if the given service is registered in the provider. If you make a call to GetService<T> for a service that doesn't exist, you'll get an exception. More...
 
object GetService (Type t)
 Finds an instance of a service given the type parameter. All services are lazily initialized, so its possible that if is the first time the type of service has been requested, this call could allocate a new instance of the service. More...
 
async Promise Dispose ()
 Disposing a IDependencyProviderScope will call IBeamableDisposable.OnDispose on all inner services that implement IBeamableDisposable. Also, after the dispose method has been called, any call to IDependencyProvider.GetService will fail. After this method, the IsDisposed will be true. However, if you re-hydrate a scope using the Hydrate method, then the scope is no longer in a disposed state. More...
 
void Hydrate (IDependencyProviderScope other)
 It is possible to "un-dispose" a scope. Hydrating a scope from another scope copies all of the services from the other scope, and uses the other scope's service descriptors to create new services. Any children will be re-hydrated and their original configuration methods will be re-fire. After this method, the IsDisposed will be false. More...
 
IDependencyProviderScope Fork (Action< IDependencyBuilder > configure=null)
 Create a new IDependencyProviderScope, using the current instance as a parent. Any service that was registered as a Scoped service will be re-created in the new provider. Any service that was registered as a Singleton will use the instance from the parent provider. If the parent provider has IDependencyProviderScope.Dispose called, then the child provider will also be disposed. More...
 

Public Attributes

Guid Id = Guid.NewGuid()
 

Properties

bool IsDisposed [get]
 
IEnumerable< ServiceDescriptorTransientServices [get]
 
IEnumerable< ServiceDescriptorScopedServices [get]
 
IEnumerable< ServiceDescriptorSingletonServices [get]
 
IDependencyProviderScope Parent [get]
 
IEnumerable< IDependencyProviderScopeChildren [get]
 
- Properties inherited from Beamable.Common.Dependencies.IDependencyProviderScope
IDependencyProviderScope Parent [get]
 Using the IDependencyProvider.Fork method allows you to create hierarchical IDependencyProviderScope. If this scope has a parent, this will point to it, or be null.
 
IEnumerable< IDependencyProviderScopeChildren [get]
 Using the IDependencyProvider.Fork method allows you to create hierarchical IDependencyProviderScope. If this scope has any children, this enumeration shows them, or it will be empty.
 
bool IsDisposed [get]
 By default, returns false. Returns true after Dispose completed. If Hydrate is run, then this returns false again.
 
IEnumerable< ServiceDescriptorTransientServices [get]
 An enumerable set of the ServiceDescriptors that are attached to this provider as transient
 
IEnumerable< ServiceDescriptorScopedServices [get]
 An enumerable set of the ServiceDescriptors that are attached to this provider as scoped
 
IEnumerable< ServiceDescriptorSingletonServices [get]
 An enumerable set of the ServiceDescriptors that are attached to this provider as singleton
 

Member Function Documentation

◆ CanBuildService()

bool Beamable.Common.Dependencies.DependencyProvider.CanBuildService ( Type  t)
inline

Returns true if the given service is registered in the provider. If you make a call to GetService<T> for a service that doesn't exist, you'll get an exception.

Parameters
tthe type of service to check for
Returns
True if the service can be got, False otherwise.

Implements Beamable.Common.Dependencies.IDependencyProvider.

◆ CanBuildService< T >()

Returns true if the given service is registered in the provider. If you make a call to GetService<T> for a service that doesn't exist, you'll get an exception.

Template Parameters
TThe type of service to get
Returns
True if the service can be got, False otherwise.

Implements Beamable.Common.Dependencies.IDependencyProvider.

◆ Dispose()

async Promise Beamable.Common.Dependencies.DependencyProvider.Dispose ( )
inline

Disposing a IDependencyProviderScope will call IBeamableDisposable.OnDispose on all inner services that implement IBeamableDisposable. Also, after the dispose method has been called, any call to IDependencyProvider.GetService will fail. After this method, the IsDisposed will be true. However, if you re-hydrate a scope using the Hydrate method, then the scope is no longer in a disposed state.

Returns
A promise capturing when the disposal will complete.

Implements Beamable.Common.Dependencies.IDependencyProviderScope.

◆ Fork()

IDependencyProviderScope Beamable.Common.Dependencies.DependencyProvider.Fork ( Action< IDependencyBuilder configure = null)
inline

Create a new IDependencyProviderScope, using the current instance as a parent. Any service that was registered as a Scoped service will be re-created in the new provider. Any service that was registered as a Singleton will use the instance from the parent provider. If the parent provider has IDependencyProviderScope.Dispose called, then the child provider will also be disposed.

Parameters
configureOptionally, you can pass a configuration function that registers new services specific to the child provider.
Returns
A new IDependencyProviderScope

Implements Beamable.Common.Dependencies.IDependencyProvider.

◆ GetService()

object Beamable.Common.Dependencies.DependencyProvider.GetService ( Type  t)
inline

Finds an instance of a service given the type parameter. All services are lazily initialized, so its possible that if is the first time the type of service has been requested, this call could allocate a new instance of the service.

If the service wasn't registered, you'll get an exception. Use CanBuildService<T> to check if the service can be got.

Parameters
tthe type of service to get
Returns
An instance of the type requested

Implements Beamable.Common.Dependencies.IDependencyProvider.

◆ GetService< T >()

Finds an instance of a service given the type parameter. All services are lazily initialized, so its possible that if is the first time the type of service has been requested, this call could allocate a new instance of the service.

If the service wasn't registered, you'll get an exception. Use CanBuildService<T> to check if the service can be got.

Template Parameters
TThe type of service to get
Returns
An instance of T

Implements Beamable.Common.Dependencies.IDependencyProvider.

◆ Hydrate()

void Beamable.Common.Dependencies.DependencyProvider.Hydrate ( IDependencyProviderScope  serviceScope)
inline

It is possible to "un-dispose" a scope. Hydrating a scope from another scope copies all of the services from the other scope, and uses the other scope's service descriptors to create new services. Any children will be re-hydrated and their original configuration methods will be re-fire. After this method, the IsDisposed will be false.

This method can be useful to re-use an instance of a IDependencyProviderScope that had been disposed.

Parameters
serviceScopeThe scope to get life from.

Implements Beamable.Common.Dependencies.IDependencyProviderScope.


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