Struct MessageEnvelopeBuilder
Builder for creating MessageEnvelopeStruct instances with pooled resources.
public struct MessageEnvelopeBuilder : IEquatable<MessageEnvelopeBuilder>
- Implements
- Inherited Members
- Extension Methods
Methods
Build()
Constructs the final MessageEnvelopeStruct with all configured properties.
public MessageEnvelopeStruct Build()
Returns
- MessageEnvelopeStruct
A new MessageEnvelopeStruct instance containing all the configured values.
Dispose()
Releases any resources associated with the builder (no resources to dispose for this struct).
public readonly void Dispose()
Equals(MessageEnvelopeBuilder)
Determines whether the specified builder is equal to the current builder.
public readonly bool Equals(MessageEnvelopeBuilder other)
Parameters
otherMessageEnvelopeBuilder
Returns
Equals(object?)
Determines whether the specified object is equal to the current builder.
public override readonly bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
Returns the hash code for this builder.
public override readonly int GetHashCode()
Returns
WithBody(ReadOnlyMemory<byte>)
Sets the message body content as a byte array.
public MessageEnvelopeBuilder WithBody(ReadOnlyMemory<byte> body)
Parameters
bodyReadOnlyMemory<byte>The serialized message body content.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithCorrelationId(string)
Sets the correlation identifier for message tracing and correlation.
public MessageEnvelopeBuilder WithCorrelationId(string correlationId)
Parameters
correlationIdstringThe correlation identifier that links related messages.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithHeader(string, string)
Adds or updates a single header in the message envelope.
public MessageEnvelopeBuilder WithHeader(string key, string value)
Parameters
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithHeaders(params (string key, string value)[])
Adds or updates multiple headers in the message envelope.
public MessageEnvelopeBuilder WithHeaders(params (string key, string value)[] headers)
Parameters
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
Exceptions
- ArgumentNullException
Thrown when headers is null.
WithMessageId(string)
Sets the message identifier for the envelope.
public MessageEnvelopeBuilder WithMessageId(string messageId)
Parameters
messageIdstringThe unique identifier for the message.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithMessageType(string)
Sets the message type identifier for routing and deserialization.
public MessageEnvelopeBuilder WithMessageType(string messageType)
Parameters
messageTypestringThe type identifier of the message content.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithPriority(byte)
Sets the message priority level for queue processing order.
public MessageEnvelopeBuilder WithPriority(byte priority)
Parameters
prioritybyteThe priority level (0-255, with higher values indicating higher priority).
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithTimeToLive(TimeSpan)
Sets the time-to-live duration for the message before it expires.
public MessageEnvelopeBuilder WithTimeToLive(TimeSpan timeToLive)
Parameters
timeToLiveTimeSpanThe maximum duration the message should remain valid.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithTimestamp(DateTime)
Sets the message timestamp using a DateTime value.
public MessageEnvelopeBuilder WithTimestamp(DateTime timestamp)
Parameters
timestampDateTimeThe timestamp when the message was created.
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
WithTimestampTicks(long)
Sets the message timestamp using tick values for high-precision timing.
public MessageEnvelopeBuilder WithTimestampTicks(long timestampTicks)
Parameters
timestampTickslongThe timestamp in ticks (100-nanosecond intervals).
Returns
- MessageEnvelopeBuilder
The current builder instance for fluent chaining.
Operators
operator ==(MessageEnvelopeBuilder, MessageEnvelopeBuilder)
Determines whether two builders are equal.
public static bool operator ==(MessageEnvelopeBuilder left, MessageEnvelopeBuilder right)
Parameters
leftMessageEnvelopeBuilderrightMessageEnvelopeBuilder
Returns
operator !=(MessageEnvelopeBuilder, MessageEnvelopeBuilder)
Determines whether two builders are not equal.
public static bool operator !=(MessageEnvelopeBuilder left, MessageEnvelopeBuilder right)
Parameters
leftMessageEnvelopeBuilderrightMessageEnvelopeBuilder