Show / Hide Table of Contents

Class ServiceLocator

Inheritance
object
ServiceLocator
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: GigaCreation.Tools.Service
Assembly: GigaCreation.Tools.Service.dll
Syntax
public static class ServiceLocator

Methods

| Improve this Doc View Source

Get<TService>(bool)

Get a service.

Declaration
public static TService Get<TService>(bool includeDerivedType = false) where TService : class, IService
Parameters
Type Name Description
bool includeDerivedType

If true, the search includes derived types.

Returns
Type Description
TService

The service of the requested type.

Type Parameters
Name Description
TService

The type of a service.

| Improve this Doc View Source

IsRegistered<TService>(bool)

Checks if a service of the specified type is registered.

Declaration
public static bool IsRegistered<TService>(bool includeDerivedType = false) where TService : class, IService
Parameters
Type Name Description
bool includeDerivedType

If true, the search includes derived types.

Returns
Type Description
bool

Returns true if a service of the given type is registered.

Type Parameters
Name Description
TService

The type of a service to check.

| Improve this Doc View Source

IsRegistered<TService>(TService, bool)

Checks if the specified service is registered.

Declaration
public static bool IsRegistered<TService>(TService service, bool includeDerivedType = false) where TService : class, IService
Parameters
Type Name Description
TService service

The service to check.

bool includeDerivedType

If true, the search includes derived types.

Returns
Type Description
bool

Returns true if the given service is registered.

Type Parameters
Name Description
TService

The type of a service to check.

| Improve this Doc View Source

Register<TService>(TService)

Register a service. If a service of the same type is already registered, you should unregister it first.

Declaration
public static void Register<TService>(TService service) where TService : class, IService
Parameters
Type Name Description
TService service

The service to register.

Type Parameters
Name Description
TService

The type of the service.

| Improve this Doc View Source

TryGet<TService>(out TService, bool)

Try to get a service.

Declaration
public static bool TryGet<TService>(out TService service, bool includeDerivedType = false) where TService : class, IService
Parameters
Type Name Description
TService service

The service of the requested type.

bool includeDerivedType

If true, the search includes derived types.

Returns
Type Description
bool

Returns true if the get was successful.

Type Parameters
Name Description
TService

The type of a service.

| Improve this Doc View Source

UnregisterAsync<TService>(TService)

Unregister a service asynchronously.

Declaration
public static ValueTask UnregisterAsync<TService>(TService service) where TService : class, IService
Parameters
Type Name Description
TService service

The service to unregister.

Returns
Type Description
ValueTask
Type Parameters
Name Description
TService

The type of the service.

| Improve this Doc View Source

Unregister<TService>(TService)

Unregister a service.

Declaration
public static void Unregister<TService>(TService service) where TService : class, IService
Parameters
Type Name Description
TService service

The service to unregister.

Type Parameters
Name Description
TService

The type of the service.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX