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