|
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 |
|
34 | 35 | namespace RabbitMQ.Client.Impl
|
35 | 36 | {
|
36 | 37 | #nullable enable
|
37 | 38 | internal readonly struct RecordedConsumer : IRecordedConsumer
|
38 | 39 | {
|
39 |
| - public AutorecoveringChannel Channel { get; } |
40 |
| - public IBasicConsumer Consumer { get; } |
41 |
| - public string Queue { get; } |
42 |
| - public bool AutoAck { get; } |
43 |
| - public string ConsumerTag { get; } |
44 |
| - public bool Exclusive { get; } |
45 |
| - public IDictionary<string, object>? Arguments { get; } |
| 40 | + private readonly AutorecoveringChannel _channel; |
| 41 | + private readonly IBasicConsumer _consumer; |
| 42 | + private readonly string _queue; |
| 43 | + private readonly bool _autoAck; |
| 44 | + private readonly string _consumerTag; |
| 45 | + private readonly bool _exclusive; |
| 46 | + private readonly IDictionary<string, object>? _arguments; |
46 | 47 |
|
47 |
| - public RecordedConsumer(AutorecoveringChannel channel, IBasicConsumer consumer, string queue, bool autoAck, string consumerTag, bool exclusive, IDictionary<string, object>? arguments) |
| 48 | + public RecordedConsumer(AutorecoveringChannel channel, IBasicConsumer consumer, string consumerTag, string queue, bool autoAck, bool exclusive, IDictionary<string, object>? arguments) |
48 | 49 | {
|
49 |
| - Channel = channel; |
50 |
| - Consumer = consumer; |
51 |
| - Queue = queue; |
52 |
| - AutoAck = autoAck; |
53 |
| - ConsumerTag = consumerTag; |
54 |
| - Exclusive = exclusive; |
55 |
| - Arguments = arguments; |
| 50 | + if (channel == null) |
| 51 | + { |
| 52 | + throw new ArgumentNullException(nameof(channel)); |
| 53 | + } |
| 54 | + _channel = channel; |
| 55 | + |
| 56 | + if (consumer == null) |
| 57 | + { |
| 58 | + throw new ArgumentNullException(nameof(consumer)); |
| 59 | + } |
| 60 | + _consumer = consumer; |
| 61 | + |
| 62 | + if (string.IsNullOrEmpty(queue)) |
| 63 | + { |
| 64 | + throw new ArgumentNullException(nameof(queue)); |
| 65 | + } |
| 66 | + _queue = queue; |
| 67 | + |
| 68 | + if (string.IsNullOrEmpty(consumerTag)) |
| 69 | + { |
| 70 | + throw new ArgumentNullException(nameof(consumerTag)); |
| 71 | + } |
| 72 | + _consumerTag = consumerTag; |
| 73 | + |
| 74 | + _autoAck = autoAck; |
| 75 | + _exclusive = exclusive; |
| 76 | + _arguments = arguments; |
56 | 77 | }
|
57 | 78 |
|
| 79 | + public AutorecoveringChannel Channel => _channel; |
| 80 | + public IBasicConsumer Consumer => _consumer; |
| 81 | + public string Queue => _queue; |
| 82 | + public bool AutoAck => _autoAck; |
| 83 | + public string ConsumerTag => _consumerTag; |
| 84 | + public bool Exclusive => _exclusive; |
| 85 | + public IDictionary<string, object>? Arguments => _arguments; |
| 86 | + |
58 | 87 | public static RecordedConsumer WithNewConsumerTag(string newTag, in RecordedConsumer old)
|
59 | 88 | {
|
60 |
| - return new RecordedConsumer(old.Channel, old.Consumer, old.Queue, old.AutoAck, newTag, old.Exclusive, old.Arguments); |
| 89 | + return new RecordedConsumer(old.Channel, old.Consumer, newTag, old.Queue, old.AutoAck, old.Exclusive, old.Arguments); |
61 | 90 | }
|
62 | 91 |
|
63 | 92 | public static RecordedConsumer WithNewQueueNameTag(string newQueueName, in RecordedConsumer old)
|
64 | 93 | {
|
65 |
| - return new RecordedConsumer(old.Channel, old.Consumer, newQueueName, old.AutoAck, old.ConsumerTag, old.Exclusive, old.Arguments); |
| 94 | + return new RecordedConsumer(old.Channel, old.Consumer, old.ConsumerTag, newQueueName, old.AutoAck, old.Exclusive, old.Arguments); |
66 | 95 | }
|
67 | 96 |
|
68 | 97 | public string Recover(IChannel channel)
|
|
0 commit comments