| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.ComponentModel; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.ServiceBus |
| | 8 | | { |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// The set of options that can be specified to influence the way in which an service bus message batch |
| | 12 | | /// behaves and is sent to the Queue/Topic. |
| | 13 | | /// </summary> |
| | 14 | | /// |
| | 15 | | public class CreateMessageBatchOptions |
| | 16 | | { |
| | 17 | | /// <summary>The requested maximum size to allow for the batch, in bytes.</summary> |
| | 18 | | private long? _maxSizeInBytes = null; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// The maximum size to allow for a single batch of messages, in bytes. |
| | 22 | | /// </summary> |
| | 23 | | /// |
| | 24 | | /// <value> |
| | 25 | | /// The desired limit, in bytes, for the size of the associated service bus message batch. If <c>null</c>, |
| | 26 | | /// the maximum size allowed by the active transport will be used. |
| | 27 | | /// </value> |
| | 28 | | /// |
| | 29 | | public long? MaxSizeInBytes |
| | 30 | | { |
| 54 | 31 | | get => _maxSizeInBytes; |
| | 32 | |
|
| | 33 | | set |
| | 34 | | { |
| 28 | 35 | | if (value.HasValue) |
| | 36 | | { |
| 26 | 37 | | Argument.AssertAtLeast(value.Value, ServiceBusSender.MinimumBatchSizeLimit, nameof(MaxSizeInBytes)); |
| | 38 | | } |
| | 39 | |
|
| 28 | 40 | | _maxSizeInBytes = value; |
| 28 | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Determines whether the specified <see cref="System.Object" /> is equal to this instance. |
| | 46 | | /// </summary> |
| | 47 | | /// |
| | 48 | | /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> |
| | 49 | | /// |
| | 50 | | /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c> |
| | 51 | | /// |
| | 52 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 53 | | public override bool Equals(object obj) => base.Equals(obj); |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Returns a hash code for this instance. |
| | 57 | | /// </summary> |
| | 58 | | /// |
| | 59 | | /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha |
| | 60 | | /// |
| | 61 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 62 | | public override int GetHashCode() => base.GetHashCode(); |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// Converts the instance to string representation. |
| | 66 | | /// </summary> |
| | 67 | | /// |
| | 68 | | /// <returns>A <see cref="System.String" /> that represents this instance.</returns> |
| | 69 | | /// |
| | 70 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 71 | | public override string ToString() => base.ToString(); |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// Creates a new copy of the current <see cref="CreateMessageBatchOptions" />, cloning its attributes into a |
| | 75 | | /// </summary> |
| | 76 | | /// |
| | 77 | | /// <returns>A new copy of <see cref="CreateMessageBatchOptions" />.</returns> |
| | 78 | | /// |
| | 79 | | internal CreateMessageBatchOptions Clone() => |
| 0 | 80 | | new CreateMessageBatchOptions |
| 0 | 81 | | { |
| 0 | 82 | | _maxSizeInBytes = MaxSizeInBytes |
| 0 | 83 | | }; |
| | 84 | | } |
| | 85 | | } |