|
29 | 29 | // Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
|
30 | 30 | //---------------------------------------------------------------------------
|
31 | 31 |
|
| 32 | +using System; |
32 | 33 | using System.Collections.Generic;
|
33 | 34 | using System.Text;
|
34 | 35 | using RabbitMQ.Client.Impl;
|
@@ -197,73 +198,63 @@ public BasicProperties()
|
197 | 198 | {
|
198 | 199 | }
|
199 | 200 |
|
200 |
| - public override ushort ProtocolClassId => 60; |
201 |
| - public override string ProtocolClassName => "basic"; |
202 |
| - |
203 |
| - internal override void ReadPropertiesFrom(ref ContentHeaderPropertyReader reader) |
| 201 | + public BasicProperties(ReadOnlySpan<byte> span) |
204 | 202 | {
|
205 |
| - bool contentType_present = reader.ReadPresence(); |
206 |
| - bool contentEncoding_present = reader.ReadPresence(); |
207 |
| - bool headers_present = reader.ReadPresence(); |
208 |
| - bool deliveryMode_present = reader.ReadPresence(); |
209 |
| - bool priority_present = reader.ReadPresence(); |
210 |
| - bool correlationId_present = reader.ReadPresence(); |
211 |
| - bool replyTo_present = reader.ReadPresence(); |
212 |
| - bool expiration_present = reader.ReadPresence(); |
213 |
| - bool messageId_present = reader.ReadPresence(); |
214 |
| - bool timestamp_present = reader.ReadPresence(); |
215 |
| - bool type_present = reader.ReadPresence(); |
216 |
| - bool userId_present = reader.ReadPresence(); |
217 |
| - bool appId_present = reader.ReadPresence(); |
218 |
| - bool clusterId_present = reader.ReadPresence(); |
219 |
| - reader.FinishPresence(); |
220 |
| - if (contentType_present) { _contentType = reader.ReadShortstr(); } |
221 |
| - if (contentEncoding_present) { _contentEncoding = reader.ReadShortstr(); } |
222 |
| - if (headers_present) { _headers = reader.ReadTable(); } |
223 |
| - if (deliveryMode_present) { _deliveryMode = reader.ReadOctet(); } |
224 |
| - if (priority_present) { _priority = reader.ReadOctet(); } |
225 |
| - if (correlationId_present) { _correlationId = reader.ReadShortstr(); } |
226 |
| - if (replyTo_present) { _replyTo = reader.ReadShortstr(); } |
227 |
| - if (expiration_present) { _expiration = reader.ReadShortstr(); } |
228 |
| - if (messageId_present) { _messageId = reader.ReadShortstr(); } |
229 |
| - if (timestamp_present) { _timestamp = reader.ReadTimestamp(); } |
230 |
| - if (type_present) { _type = reader.ReadShortstr(); } |
231 |
| - if (userId_present) { _userId = reader.ReadShortstr(); } |
232 |
| - if (appId_present) { _appId = reader.ReadShortstr(); } |
233 |
| - if (clusterId_present) { _clusterId = reader.ReadShortstr(); } |
| 203 | + int offset = WireFormatting.ReadBits(span, |
| 204 | + out bool contentType_present, |
| 205 | + out bool contentEncoding_present, |
| 206 | + out bool headers_present, |
| 207 | + out bool deliveryMode_present, |
| 208 | + out bool priority_present, |
| 209 | + out bool correlationId_present, |
| 210 | + out bool replyTo_present, |
| 211 | + out bool expiration_present, |
| 212 | + out bool messageId_present, |
| 213 | + out bool timestamp_present, |
| 214 | + out bool type_present, |
| 215 | + out bool userId_present, |
| 216 | + out bool appId_present, |
| 217 | + out bool clusterId_present); |
| 218 | + if (contentType_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _contentType); } |
| 219 | + if (contentEncoding_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _contentEncoding); } |
| 220 | + if (headers_present) { offset += WireFormatting.ReadDictionary(span.Slice(offset), out var tmpDirectory); _headers = tmpDirectory; } |
| 221 | + if (deliveryMode_present) { _deliveryMode = span[offset++]; } |
| 222 | + if (priority_present) { _priority = span[offset++]; } |
| 223 | + if (correlationId_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _correlationId); } |
| 224 | + if (replyTo_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _replyTo); } |
| 225 | + if (expiration_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _expiration); } |
| 226 | + if (messageId_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _messageId); } |
| 227 | + if (timestamp_present) { offset += WireFormatting.ReadTimestamp(span.Slice(offset), out _timestamp); } |
| 228 | + if (type_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _type); } |
| 229 | + if (userId_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _userId); } |
| 230 | + if (appId_present) { offset += WireFormatting.ReadShortstr(span.Slice(offset), out _appId); } |
| 231 | + if (clusterId_present) { WireFormatting.ReadShortstr(span.Slice(offset), out _clusterId); } |
234 | 232 | }
|
235 | 233 |
|
236 |
| - internal override void WritePropertiesTo(ref ContentHeaderPropertyWriter writer) |
| 234 | + public override ushort ProtocolClassId => 60; |
| 235 | + public override string ProtocolClassName => "basic"; |
| 236 | + |
| 237 | + internal override int WritePropertiesTo(Span<byte> span) |
237 | 238 | {
|
238 |
| - writer.WritePresence(IsContentTypePresent()); |
239 |
| - writer.WritePresence(IsContentEncodingPresent()); |
240 |
| - writer.WritePresence(IsHeadersPresent()); |
241 |
| - writer.WritePresence(IsDeliveryModePresent()); |
242 |
| - writer.WritePresence(IsPriorityPresent()); |
243 |
| - writer.WritePresence(IsCorrelationIdPresent()); |
244 |
| - writer.WritePresence(IsReplyToPresent()); |
245 |
| - writer.WritePresence(IsExpirationPresent()); |
246 |
| - writer.WritePresence(IsMessageIdPresent()); |
247 |
| - writer.WritePresence(IsTimestampPresent()); |
248 |
| - writer.WritePresence(IsTypePresent()); |
249 |
| - writer.WritePresence(IsUserIdPresent()); |
250 |
| - writer.WritePresence(IsAppIdPresent()); |
251 |
| - writer.WritePresence(IsClusterIdPresent()); |
252 |
| - writer.FinishPresence(); |
253 |
| - if (IsContentTypePresent()) { writer.WriteShortstr(_contentType); } |
254 |
| - if (IsContentEncodingPresent()) { writer.WriteShortstr(_contentEncoding); } |
255 |
| - if (IsHeadersPresent()) { writer.WriteTable(_headers); } |
256 |
| - if (IsDeliveryModePresent()) { writer.WriteOctet(_deliveryMode); } |
257 |
| - if (IsPriorityPresent()) { writer.WriteOctet(_priority); } |
258 |
| - if (IsCorrelationIdPresent()) { writer.WriteShortstr(_correlationId); } |
259 |
| - if (IsReplyToPresent()) { writer.WriteShortstr(_replyTo); } |
260 |
| - if (IsExpirationPresent()) { writer.WriteShortstr(_expiration); } |
261 |
| - if (IsMessageIdPresent()) { writer.WriteShortstr(_messageId); } |
262 |
| - if (IsTimestampPresent()) { writer.WriteTimestamp(_timestamp); } |
263 |
| - if (IsTypePresent()) { writer.WriteShortstr(_type); } |
264 |
| - if (IsUserIdPresent()) { writer.WriteShortstr(_userId); } |
265 |
| - if (IsAppIdPresent()) { writer.WriteShortstr(_appId); } |
266 |
| - if (IsClusterIdPresent()) { writer.WriteShortstr(_clusterId); } |
| 239 | + int offset = WireFormatting.WriteBits(span, |
| 240 | + IsContentTypePresent(), IsContentEncodingPresent(), IsHeadersPresent(), IsDeliveryModePresent(), IsPriorityPresent(), |
| 241 | + IsCorrelationIdPresent(), IsReplyToPresent(), IsExpirationPresent(), IsMessageIdPresent(), IsTimestampPresent(), |
| 242 | + IsTypePresent(), IsUserIdPresent(), IsAppIdPresent(), IsClusterIdPresent()); |
| 243 | + if (IsContentTypePresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _contentType); } |
| 244 | + if (IsContentEncodingPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _contentEncoding); } |
| 245 | + if (IsHeadersPresent()) { offset += WireFormatting.WriteTable(span.Slice(offset), _headers); } |
| 246 | + if (IsDeliveryModePresent()) { span[offset++] = _deliveryMode; } |
| 247 | + if (IsPriorityPresent()) { span[offset++] = _priority; } |
| 248 | + if (IsCorrelationIdPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _correlationId); } |
| 249 | + if (IsReplyToPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _replyTo); } |
| 250 | + if (IsExpirationPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _expiration); } |
| 251 | + if (IsMessageIdPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _messageId); } |
| 252 | + if (IsTimestampPresent()) { offset += WireFormatting.WriteTimestamp(span.Slice(offset), _timestamp); } |
| 253 | + if (IsTypePresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _type); } |
| 254 | + if (IsUserIdPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _userId); } |
| 255 | + if (IsAppIdPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _appId); } |
| 256 | + if (IsClusterIdPresent()) { offset += WireFormatting.WriteShortstr(span.Slice(offset), _clusterId); } |
| 257 | + return offset; |
267 | 258 | }
|
268 | 259 |
|
269 | 260 | public override int GetRequiredPayloadBufferSize()
|
|
0 commit comments