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