Skip to content

Class InstanceRegistry

Namespace: DotBoxD.Services.Server
Assembly: DotBoxD.Services.dll

Default DotBoxD.Services.Server.IInstanceRegistry. Backed by a single System.Collections.Concurrent.ConcurrentDictionary keyed on (serviceName, instanceId). One registry per connection.

public sealed class InstanceRegistry : IInstanceRegistry

object ← InstanceRegistry

IInstanceRegistry

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object, object), object.ToString()

public InstanceRegistry()
public InstanceRegistry(int maxInstances)

maxInstances int

Registers an instance under serviceName and returns the freshly allocated identifier the client will quote on subsequent calls. serviceName must be non-empty and non-whitespace.

public string Register(string serviceName, object instance)

serviceName string

instance object

string

Releases an instance early (the connection-teardown path also clears it). Keys must be non-empty and non-whitespace.

public void Release(string serviceName, string instanceId)

serviceName string

instanceId string

Removes every entry — called from the connection-cleanup path.

public void ReleaseAll()

Releases an instance early and awaits async disposal when no in-flight operation still holds it. Keys must be non-empty and non-whitespace.

public ValueTask ReleaseAsync(string serviceName, string instanceId)

serviceName string

instanceId string

ValueTask

TryAcquire(string, string, out object, out IAsyncDisposable)

Section titled “ TryAcquire(string, string, out object, out IAsyncDisposable)”

Acquires an instance for an in-flight operation. Dispose lease after the operation completes so a concurrent release cannot dispose the instance while it is in use. The default implementation preserves the lookup behavior for custom registries that do not own instance lifetimes.

public bool TryAcquire(string serviceName, string instanceId, out object instance, out IAsyncDisposable lease)

serviceName string

instanceId string

instance object

lease IAsyncDisposable

bool

Looks up an instance previously registered under (serviceName, instanceId). Invalid or unknown keys return false.

public bool TryGet(string serviceName, string instanceId, out object instance)

serviceName string

instanceId string

instance object

bool