Class MemoryMessageExtensions
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
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
contentTThe content to serialize.
serializerDispatchJsonSerializerThe serializer to use.
memoryPoolMemoryPool<byte>The memory pool to use for the buffer.
Returns
- MemoryMessageOfT<T>
A new typed memory message.
Type Parameters
TThe 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
memoryPoolMemoryPool<byte>The memory pool to rent from.
dataReadOnlySpan<byte>The data to copy into the pooled buffer.
contentTypestringThe 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
messageIDispatchMessageThe message to convert.
serializerDispatchJsonSerializerThe serializer to use.
memoryPoolMemoryPool<byte>The memory pool to use.
Returns
- MemoryMessage
A new memory message.