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 : IInstanceRegistryInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object, object), object.ToString()
Constructors
Section titled “Constructors”InstanceRegistry()
Section titled “ InstanceRegistry()”public InstanceRegistry()InstanceRegistry(int)
Section titled “ InstanceRegistry(int)”public InstanceRegistry(int maxInstances)Parameters
Section titled “Parameters”maxInstances int
Methods
Section titled “Methods”Register(string, object)
Section titled “ Register(string, object)”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)Parameters
Section titled “Parameters”serviceName string
instance object
Returns
Section titled “Returns”Release(string, string)
Section titled “ Release(string, 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)Parameters
Section titled “Parameters”serviceName string
instanceId string
ReleaseAll()
Section titled “ ReleaseAll()”Removes every entry — called from the connection-cleanup path.
public void ReleaseAll()ReleaseAsync(string, string)
Section titled “ ReleaseAsync(string, string)”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)Parameters
Section titled “Parameters”serviceName string
instanceId string
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”serviceName string
instanceId string
instance object
lease IAsyncDisposable
Returns
Section titled “Returns”TryGet(string, string, out object)
Section titled “ TryGet(string, string, out object)”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)Parameters
Section titled “Parameters”serviceName string
instanceId string
instance object