| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Microsoft.Azure.Amqp; |
| | 6 | | using Microsoft.Azure.Amqp.Framing; |
| | 7 | |
|
| | 8 | | namespace Azure.Messaging.ServiceBus.Amqp.Framing |
| | 9 | | { |
| | 10 | | internal sealed class AmqpRuleDescriptionCodec : DescribedList |
| | 11 | | { |
| | 12 | | public const string Name = AmqpConstants.Vendor + ":rule-description:list"; |
| | 13 | | public const ulong Code = 0x0000013700000004; |
| | 14 | | private const int Fields = 4; |
| | 15 | |
|
| 0 | 16 | | public AmqpRuleDescriptionCodec() : base(Name, Code) { } |
| | 17 | |
|
| 0 | 18 | | public AmqpRuleFilterCodec Filter { get; set; } |
| | 19 | |
|
| 0 | 20 | | public AmqpRuleActionCodec Action { get; set; } |
| | 21 | |
|
| 0 | 22 | | public string RuleName { get; set; } |
| | 23 | |
|
| 0 | 24 | | public DateTime? CreatedAt { get; set; } |
| | 25 | |
|
| 0 | 26 | | protected override int FieldCount => Fields; |
| | 27 | |
|
| | 28 | | protected override void OnEncode(ByteBuffer buffer) |
| | 29 | | { |
| 0 | 30 | | AmqpCodec.EncodeSerializable(Filter, buffer); |
| 0 | 31 | | AmqpCodec.EncodeSerializable(Action, buffer); |
| 0 | 32 | | AmqpCodec.EncodeString(RuleName, buffer); |
| 0 | 33 | | AmqpCodec.EncodeTimeStamp(CreatedAt, buffer); |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | protected override void OnDecode(ByteBuffer buffer, int count) |
| | 37 | | { |
| 0 | 38 | | if (count-- > 0) |
| | 39 | | { |
| 0 | 40 | | Filter = (AmqpRuleFilterCodec)AmqpCodec.DecodeAmqpDescribed(buffer); |
| | 41 | | } |
| | 42 | |
|
| 0 | 43 | | if (count-- > 0) |
| | 44 | | { |
| 0 | 45 | | Action = (AmqpRuleActionCodec)AmqpCodec.DecodeAmqpDescribed(buffer); |
| | 46 | | } |
| | 47 | |
|
| 0 | 48 | | if (count-- > 0) |
| | 49 | | { |
| 0 | 50 | | RuleName = AmqpCodec.DecodeString(buffer); |
| | 51 | | } |
| | 52 | |
|
| 0 | 53 | | if (count > 0) |
| | 54 | | { |
| 0 | 55 | | CreatedAt = AmqpCodec.DecodeTimeStamp(buffer); |
| | 56 | | } |
| 0 | 57 | | } |
| | 58 | |
|
| | 59 | | protected override int OnValueSize() |
| | 60 | | { |
| 0 | 61 | | return AmqpCodec.GetSerializableEncodeSize(Filter) + |
| 0 | 62 | | AmqpCodec.GetSerializableEncodeSize(Action) + |
| 0 | 63 | | AmqpCodec.GetStringEncodeSize(RuleName) + |
| 0 | 64 | | AmqpCodec.GetTimeStampEncodeSize(CreatedAt); |
| | 65 | | } |
| | 66 | | } |
| | 67 | | } |