Skip to main content
Table of Contents

Class TrustedTypeResolver

Namespace
Stratara.Abstractions.Reflections
Assembly
Stratara.Abstractions.dll

Default ITrustedTypeResolver backed by a process-wide ConcurrentDictionary<TKey, TValue> keyed by the version-independent type-name representation (assembly version / culture / public-key-token segments stripped).

public sealed class TrustedTypeResolver : ITrustedTypeResolver
Inheritance
TrustedTypeResolver
Implements
Inherited Members
Extension Methods

Remarks

Instances are intended to be registered as a singleton in the host's DI container. The DI scan extensions populate the resolver during ConfigureServices; runtime lookups (from MediatorCommandWorker, EventMapperFactory, SnapshotService) are lock-free reads.

Properties

RegisteredTypes

Snapshot of every type currently registered with the resolver.

[SuppressMessage("Major Code Smell", "S2365:Properties should not make collection or array copies", Justification = "Snapshot semantics are documented on ITrustedTypeResolver.RegisteredTypes; only consumer is the EncryptionMetadataDriftGuard at host start-up — not a hot path.")]
public IReadOnlyCollection<Type> RegisteredTypes { get; }

Property Value

IReadOnlyCollection<Type>

Remarks

Returned collection is a point-in-time snapshot — concurrent Register(Type) calls after iteration begins are not reflected. Startup validators (for example the encryption metadata drift guard) use this to walk the full allowlist once at host start.

Methods

Register(Type)

Registers type in the resolver. Registering the same type again is a no-op; registering a different type under a name already taken is rejected rather than discarded, so a name clash surfaces at registration instead of silently resolving to whichever type won.

public void Register(Type type)

Parameters

type Type

The type to register.

Exceptions

ArgumentNullException

type is null.

InvalidOperationException

type has no assembly-qualified name, or a different type is already registered under the same version-independent name.

Resolve(string)

Returns the Type matching typeName or throws InvalidOperationException.

public Type Resolve(string typeName)

Parameters

typeName string

Assembly-qualified or version-independent type name as persisted with the event / command / aggregate row.

Returns

Type

The registered runtime type.

Exceptions

ArgumentNullException

typeName is null.

InvalidOperationException

No type matching typeName has been registered.

TryResolve(string, out Type?)

Attempts to resolve typeName without throwing.

public bool TryResolve(string typeName, out Type? type)

Parameters

typeName string

Assembly-qualified or version-independent type name.

type Type

Receives the resolved type on success; null on failure.

Returns

bool

true if a registered type matched; false otherwise.