Table of Contents

Class NpgsqlServiceRegistry

Namespace
FishMMO.Database.Npgsql
Assembly
FishMMO-DB.dll

Service registry for Npgsql-based database services. Explicitly registers and owns the lifecycle of all Npgsql services. Thread-safe singleton-style registry (constructed once and then used concurrently).

public sealed class NpgsqlServiceRegistry : IDatabaseServiceRegistry
Inheritance
NpgsqlServiceRegistry
Implements
Inherited Members

Remarks

Uses ConcurrentDictionary for lock-free reads, providing excellent performance under high concurrency. Thread-safe for all operations.

Constructors

NpgsqlServiceRegistry()

Initializes a new instance of the NpgsqlServiceRegistry class. Services must be registered explicitly by the composition root.

public NpgsqlServiceRegistry()

Properties

ServiceCount

Gets the number of registered services in the registry.

public int ServiceCount { get; }

Property Value

int

Methods

GetRegisteredServiceTypes()

Gets an array of all registered service interface types.

public Type[] GetRegisteredServiceTypes()

Returns

Type[]

An array containing all registered service types.

IsRegistered(Type)

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

public 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.

public 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.

public 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.

public 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.