Table of Contents

Class MemoryMessageExtensions

Namespace
Excalibur.Dispatch.Messaging
Assembly
Excalibur.Dispatch.dll

Extension methods for creating memory messages.

public static class MemoryMessageExtensions
Inheritance
MemoryMessageExtensions
Inherited Members

Methods

FromBytes(byte[], string)

Creates a memory message from a byte array.

public static MemoryMessage FromBytes(byte[] data, string contentType = "application/octet-stream")

Parameters

data byte[]

The message data.

contentType string

The content type.

Returns

MemoryMessage

A new memory message.

FromContent<T>(T, DispatchJsonSerializer, MemoryPool<byte>)

Creates a typed memory message from an object.

[RequiresUnreferencedCode("JSON serialization for generic types requires preserved members.")]
[RequiresDynamicCode("JSON serialization for generic types requires dynamic code generation.")]
public static MemoryMessageOfT<T> FromContent<T>(T content, DispatchJsonSerializer serializer, MemoryPool<byte> memoryPool) where T : class

Parameters

content T

The content to serialize.

serializer DispatchJsonSerializer

The serializer to use.

memoryPool MemoryPool<byte>

The memory pool to use for the buffer.

Returns

MemoryMessageOfT<T>

A new typed memory message.

Type Parameters

T

The type of the content.

FromPooledBuffer(MemoryPool<byte>, ReadOnlySpan<byte>, string)

Creates a memory message from a pooled buffer.

public static MemoryMessage FromPooledBuffer(MemoryPool<byte> memoryPool, ReadOnlySpan<byte> data, string contentType = "application/octet-stream")

Parameters

memoryPool MemoryPool<byte>

The memory pool to rent from.

data ReadOnlySpan<byte>

The data to copy into the pooled buffer.

contentType string

The content type.

Returns

MemoryMessage

A new memory message with pooled memory.

ToMemoryMessage(IDispatchMessage, DispatchJsonSerializer, MemoryPool<byte>)

Converts a regular dispatch message to a memory message.

public static MemoryMessage ToMemoryMessage(this IDispatchMessage message, DispatchJsonSerializer serializer, MemoryPool<byte> memoryPool)

Parameters

message IDispatchMessage

The message to convert.

serializer DispatchJsonSerializer

The serializer to use.

memoryPool MemoryPool<byte>

The memory pool to use.

Returns

MemoryMessage

A new memory message.