Class IntegrationEventNameMap
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
contractsIEnumerable<KeyValuePair<string, Type>>The wire name to CLR type pairs to register.
Exceptions
- ArgumentNullException
contractsisnull.- 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
Names
The wire names registered in this map.
public IReadOnlyCollection<string> Names { get; }
Property Value
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
assembliesAssembly[]The assemblies holding the integration event contracts.
Returns
- IntegrationEventNameMap
The validated map.
Exceptions
- ArgumentNullException
assembliesisnull.- 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
typeTypeThe local CLR event type.
Returns
TypeFor(string)
Returns the CLR type registered for name, if any.
public Maybe<Type> TypeFor(string name)
Parameters
namestringThe wire name read from the message.