Table of Contents

Class IntegrationEventNameMap

Namespace
Trellis.Mediator
Assembly
Trellis.Mediator.dll

A bidirectional map between an integration event's stable wire name (see IntegrationEventNameAttribute) and its local CLR type — the contract a broker transport serializes through so producer and consumer never exchange assembly-qualified type names.

public sealed class IntegrationEventNameMap
Inheritance
IntegrationEventNameMap
Inherited Members
Extension Methods

Remarks

The map is immutable and validated at construction: an unusable contract surfaces when the application starts rather than when a message arrives at three in the morning. Every rejection is a contract bug that cannot be recovered from at runtime — two events claiming one name would make the wire ambiguous, and a name resolving to a type that is not an IIntegrationEvent could never be dispatched.

Lookups return Maybe<T> rather than throwing, because an unknown name is a normal operational condition: a producer may legitimately emit events this consumer does not subscribe to, and the transport should dead-letter or ignore them by policy rather than crash.

Constructors

IntegrationEventNameMap(IEnumerable<KeyValuePair<string, Type>>)

Creates a map from explicit name/type pairs. This overload is trimming- and NativeAOT-safe; prefer it over FromAssemblies(params Assembly[]) when publishing a trimmed application.

public IntegrationEventNameMap(IEnumerable<KeyValuePair<string, Type>> contracts)

Parameters

contracts IEnumerable<KeyValuePair<string, Type>>

The wire name to CLR type pairs to register.

Exceptions

ArgumentNullException

contracts is null.

ArgumentException

A name is empty, a type does not implement IIntegrationEvent, is not concrete, or has unbound generic parameters, or a name or type appears more than once.

Properties

Empty

An empty map: every lookup returns None.

public static IntegrationEventNameMap Empty { get; }

Property Value

IntegrationEventNameMap

Names

The wire names registered in this map.

public IReadOnlyCollection<string> Names { get; }

Property Value

IReadOnlyCollection<string>

Methods

FromAssemblies(params Assembly[])

Builds a map by scanning assemblies for concrete IIntegrationEvent types carrying IntegrationEventNameAttribute. Types without the attribute are skipped, so a contract assembly can hold events that are deliberately in-process only.

[RequiresUnreferencedCode("Scans assemblies for IIntegrationEvent types annotated with IntegrationEventNameAttribute; the types may be trimmed. Use the IEnumerable<KeyValuePair<string, Type>> constructor in trimmed applications.")]
public static IntegrationEventNameMap FromAssemblies(params Assembly[] assemblies)

Parameters

assemblies Assembly[]

The assemblies holding the integration event contracts.

Returns

IntegrationEventNameMap

The validated map.

Exceptions

ArgumentNullException

assemblies is null.

ArgumentException

Two scanned types declare the same wire name.

NameFor(Type)

Returns the wire name registered for type, if any.

public Maybe<string> NameFor(Type type)

Parameters

type Type

The local CLR event type.

Returns

Maybe<string>

The wire name, or None when the type has no registered contract.

TypeFor(string)

Returns the CLR type registered for name, if any.

public Maybe<Type> TypeFor(string name)

Parameters

name string

The wire name read from the message.

Returns

Maybe<Type>

The CLR type, or None when this application knows no such contract.