Interface IMessageMapper<TSource, TTarget>
Defines a typed mapper that transforms messages between specific source and target types.
public interface IMessageMapper<in TSource, out TTarget>
Type Parameters
TSourceThe source message type.
TTargetThe target message type.
- Extension Methods
Remarks
Use this interface when you need to transform the message payload itself, not just the transport context. This is useful for:
- Converting between internal and external message formats
- Version upgrades/downgrades for message schemas
- Enriching messages with additional data
Methods
Map(TSource, ITransportMessageContext)
Maps a source message to a target message type.
TTarget Map(TSource source, ITransportMessageContext context)
Parameters
sourceTSourceThe source message to transform.
contextITransportMessageContextThe transport context for the mapping operation.
Returns
- TTarget
The transformed target message.
Exceptions
- ArgumentNullException
Thrown when
sourceis null.