Class CoreRegistry
A container to store all available IServiceComponent and services in the project.
Inherited Members
Namespace: Unity.Services.Core.Internal
Assembly: Unity.Services.Core.Internal.dll
Syntax
public sealed class CoreRegistry
Properties
Instance
Get the main registry of this project.
Declaration
public static CoreRegistry Instance { get; }
Property Value
| Type | Description |
|---|---|
| CoreRegistry |
InstanceId
The unique identifier of the instance.
Declaration
public string InstanceId { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetServiceComponent<TComponent>()
Get the instance of the given IServiceComponent type.
Declaration
public TComponent GetServiceComponent<TComponent>() where TComponent : IServiceComponent
Returns
| Type | Description |
|---|---|
| TComponent | Return the instance of the given IServiceComponent type if it has been registered; throws an exception otherwise. |
Type Parameters
| Name | Description |
|---|---|
| TComponent | The type of IServiceComponent to get. |
Exceptions
| Type | Condition |
|---|---|
| KeyNotFoundException | Thrown if the requested type of |
GetService<T>()
Returns the given service in this registry.
Declaration
public T GetService<T>()
Returns
| Type | Description |
|---|---|
| T | Return the instance of the given service type if it has been registered; returns null otherwise. |
Type Parameters
| Name | Description |
|---|---|
| T | The interface type of service to get. |
RegisterPackage<TPackage>(TPackage)
Store the given package in this registry.
Declaration
public CoreRegistration RegisterPackage<TPackage>(TPackage package) where TPackage : IInitializablePackage
Parameters
| Type | Name | Description |
|---|---|---|
| TPackage | package | The service package instance to register. |
Returns
| Type | Description |
|---|---|
| CoreRegistration | Return a handle to the registered |
Type Parameters
| Name | Description |
|---|---|
| TPackage | The type of IInitializablePackage to register. |
RegisterServiceComponent<TComponent>(TComponent)
Store the given component in this registry.
Declaration
public void RegisterServiceComponent<TComponent>(TComponent component) where TComponent : IServiceComponent
Parameters
| Type | Name | Description |
|---|---|---|
| TComponent | component | The component instance to register. |
Type Parameters
| Name | Description |
|---|---|
| TComponent | The type of IServiceComponent to register. |
RegisterService<T>(T)
Store the given service in this registry.
Declaration
public void RegisterService<T>(T service)
Parameters
| Type | Name | Description |
|---|---|---|
| T | service | The service instance to register. |
Type Parameters
| Name | Description |
|---|---|
| T | The interface type of the service to register. |
TryGetServiceComponent<TComponent>(out TComponent)
Get the instance of the given IServiceComponent type and if it is registered.
Declaration
public bool TryGetServiceComponent<TComponent>(out TComponent component) where TComponent : IServiceComponent
Parameters
| Type | Name | Description |
|---|---|---|
| TComponent | component | The component instance or the default value |
Returns
| Type | Description |
|---|---|
| bool | If the component was found in the registry. |
Type Parameters
| Name | Description |
|---|---|
| TComponent | The type of IServiceComponent to get. |