-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ContentTransferOptions.cs
96 lines (86 loc) · 4.08 KB
/
ContentTransferOptions.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
88
89
90
91
92
93
94
95
96
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.ComponentModel;
namespace Azure.Communication.CallingServer
{
/// <summary>
/// <see cref="ContentTransferOptions"/> is used to provide options for parallel transfers.
/// </summary>
public struct ContentTransferOptions : IEquatable<ContentTransferOptions>
{
private long? _maximumTransferSize;
private int? _maximumConcurrency;
private long? _initialTransferSize;
/// <summary>
/// The maximum length of a transfer in bytes.
/// </summary>
public long MaximumTransferSize
{
get { return _maximumTransferSize ?? Constants.ContentDownloader.Partition.MaxDownloadBytes; }
set { _maximumTransferSize = value; }
}
/// <summary>
/// The maximum number of workers that may be used in a parallel transfer.
/// </summary>
public int MaximumConcurrency
{
get { return _maximumConcurrency ?? Constants.ContentDownloader.Partition.DefaultConcurrentTransfersCount; }
set { _maximumConcurrency = value; }
}
/// <summary>
/// The size of the first range request in bytes. Blobs smaller than this limit will
/// be downloaded in a single request. Blobs larger than this limit will continue being
/// downloaded in chunks of size <see cref="MaximumTransferSize"/>.
/// </summary>
public long InitialTransferSize
{
get { return _initialTransferSize ?? Constants.ContentDownloader.Partition.DefaultInitalDownloadRangeSize; }
set { _initialTransferSize = value; }
}
/// <summary>
/// Check if two ContentTransferOptions instances are equal.
/// </summary>
/// <param name="obj">The instance to compare to.</param>
/// <returns>True if they're equal, false otherwise.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
=> obj is ContentTransferOptions other
&& Equals(other);
/// <summary>
/// Get a hash code for the ParallelTransferOptions.
/// </summary>
/// <returns>Hash code for the ParallelTransferOptions.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode()
=> MaximumTransferSize.GetHashCode()
^ MaximumConcurrency.GetHashCode()
^ InitialTransferSize.GetHashCode();
/// <summary>
/// Check if two ParallelTransferOptions instances are equal.
/// </summary>
/// <param name="left">The first instance to compare.</param>
/// <param name="right">The second instance to compare.</param>
/// <returns>True if they're equal, false otherwise.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool operator ==(ContentTransferOptions left, ContentTransferOptions right) => left.Equals(right);
/// <summary>
/// Check if two ParallelTransferOptions instances are equal.
/// </summary>
/// <param name="left">The first instance to compare.</param>
/// <param name="right">The second instance to compare.</param>
/// <returns>True if they're not equal, false otherwise.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool operator !=(ContentTransferOptions left, ContentTransferOptions right) => !(left == right);
/// <summary>
/// Check if two ParallelTransferOptions instances are equal.
/// </summary>
/// <param name="obj">The instance to compare to.</param>
/// <returns>True if they're equal, false otherwise.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool Equals(ContentTransferOptions obj)
=> MaximumTransferSize == obj.MaximumTransferSize
&& MaximumConcurrency == obj.MaximumConcurrency
&& InitialTransferSize == obj.InitialTransferSize;
}
}