Table of Contents

Interface IDatabaseServiceRegistry

Namespace
FishMMO.Database
Assembly
FishMMO-DB.dll

Defines a contract for database service registries. Enables automatic service discovery, registration, and retrieval for database services. Follows Interface Segregation Principle and Open/Closed Principle for extensibility. Can be implemented for different database types (Npgsql, MongoDB, etc.).

public interface IDatabaseServiceRegistry

Properties

ServiceCount

Gets the number of registered services in the registry.

int ServiceCount { get; }

Property Value

int

Methods

GetRegisteredServiceTypes()

Gets an array of all registered service interface types.

Type[] GetRegisteredServiceTypes()

Returns

Type[]

An array containing all registered service types.

IsRegistered(Type)

Determines whether a service is registered for the specified interface type.

bool IsRegistered(Type serviceType)

Parameters

serviceType Type

The service interface type to check.

Returns

bool

True if the service is registered; otherwise, false.

IsRegistered<TService>()

Determines whether a service is registered for the specified interface type.

bool IsRegistered<TService>() where TService : class

Returns

bool

True if the service is registered; otherwise, false.

Type Parameters

TService

The service interface type to check.

TryGet(Type, out object)

Attempts to retrieve a service by its interface type. Runtime type resolution for dynamic service lookup.

bool TryGet(Type serviceType, out object service)

Parameters

serviceType Type

The service interface type to retrieve.

service object

When this method returns, contains the service instance if found; otherwise, null.

Returns

bool

True if the service was found; otherwise, false.

TryGet<TService>(out TService)

Attempts to retrieve a service by its interface type. Type-safe generic method for compile-time type checking.

bool TryGet<TService>(out TService service) where TService : class

Parameters

service TService

When this method returns, contains the service instance if found; otherwise, null.

Returns

bool

True if the service was found; otherwise, false.

Type Parameters

TService

The service interface type to retrieve.