Table of Contents

Class ChronicleLinkRegistry

Namespace
Chronicler
Assembly
Chronicler.dll

Maps stable IDs to host-owned values within a recording session.

public sealed class ChronicleLinkRegistry
Inheritance
ChronicleLinkRegistry
Inherited Members

Remarks

Each lookup uses the declared link type and slot. Slot names are case-sensitive. Null and empty slots select the same default slot.

Constructors

ChronicleLinkRegistry()

public ChronicleLinkRegistry()

Methods

RegisterInstance<T>(string, T, string?)

Associates a value with a stable ID.

public void RegisterInstance<T>(string id, T value, string? slot = null)

Parameters

id string

A case-sensitive ID containing at least one non-whitespace character.

value T

The value to retain. For reference types, the registry keeps the instance.

slot string

An optional identity domain. Null or empty selects the default slot.

Type Parameters

T

The declared type used by the recording schema.

Remarks

Registering the same ID for the same type and slot replaces its value in place.

Exceptions

ArgumentException

id is null, empty, or whitespace.

RegisterResolver<T>(IRecordLinkResolver<T>, string?)

Sets the custom resolver for a link type and slot.

public void RegisterResolver<T>(IRecordLinkResolver<T> resolver, string? slot = null)

Parameters

resolver IRecordLinkResolver<T>

The resolver to retain and consult before instance registrations.

slot string

An optional identity domain. Null or empty selects the default slot.

Type Parameters

T

The declared type used by the recording schema.

Remarks

Replaces any previous resolver in that type and slot.

Exceptions

ArgumentNullException

resolver is null.

TryGetReferenceId<T>(T, out string?, string?)

Looks up the stable ID for a value.

public bool TryGetReferenceId<T>(T value, out string? id, string? slot = null)

Parameters

value T

The value to identify in this session.

id string

The stable ID on success. Otherwise, null.

slot string

The link's identity domain. Null or empty selects the default slot.

Returns

bool

true if the resolver or an instance registration supplied an ID.

Type Parameters

T

The declared link type to look up.

Remarks

Consults the custom resolver first. Instance lookup uses reference identity for reference types and default equality for value types. If several registrations match, returns the first in registration order.

TryResolve<T>(string, out T, string?)

Looks up the value for a recorded ID.

public bool TryResolve<T>(string id, out T value, string? slot = null)

Parameters

id string

The non-null recorded ID. Instance registrations use case-sensitive matching.

value T

The resolved value on success. Otherwise, the default value of T.

slot string

The recorded link's identity domain. Null or empty selects the default slot.

Returns

bool

true if the resolver or an instance registration supplied a value.

Type Parameters

T

The declared link type to look up.

Remarks

Consults the custom resolver first and falls back to instance registrations on a miss.

Exceptions

ArgumentNullException

id is null when an instance table is consulted.

UnregisterInstance<T>(string, string?)

Removes an instance registration.

public bool UnregisterInstance<T>(string id, string? slot = null)

Parameters

id string

The case-sensitive ID of the registration.

slot string

The registration's identity domain. Null or empty selects the default slot.

Returns

bool

true if the registration was removed. Returns false for a blank ID or when the type and slot contain no registration for it.

Type Parameters

T

The declared type used to register the value.

Remarks

The custom resolver for the same type and slot remains available.