-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
DataLakeRequestConditions.cs
75 lines (67 loc) · 2.4 KB
/
DataLakeRequestConditions.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Text;
namespace Azure.Storage.Files.DataLake.Models
{
/// <summary>
/// Specifies lease access conditions for a file system or path.
/// </summary>
public class DataLakeRequestConditions : RequestConditions
{
/// <summary>
/// Optionally limit requests to resources with an active lease
/// matching this Id.
/// </summary>
public string LeaseId { get; set; }
/// <summary>
/// Converts the value of the current RequestConditions object to
/// its equivalent string representation.
/// </summary>
/// <returns>
/// A string representation of the RequestConditions.
/// </returns>
public override string ToString()
{
StringBuilder conditions = new StringBuilder();
conditions.Append('[').Append(GetType().Name);
AddConditions(conditions);
if (conditions[conditions.Length - 1] == ';')
{
conditions[conditions.Length - 1] = ']';
}
else
{
conditions.Append(']');
}
return conditions.ToString();
}
/// <summary>
/// Collect any request conditions. Conditions should be separated by
/// a semicolon.
/// </summary>
/// <param name="conditions">The collected conditions.</param>
internal virtual void AddConditions(StringBuilder conditions)
{
if (IfMatch != null)
{
conditions.Append(nameof(IfMatch)).Append('=').Append(IfMatch).Append(';');
}
if (IfNoneMatch != null)
{
conditions.Append(nameof(IfNoneMatch)).Append('=').Append(IfNoneMatch).Append(';');
}
if (IfModifiedSince != null)
{
conditions.Append(nameof(IfModifiedSince)).Append('=').Append(IfModifiedSince).Append(';');
}
if (IfUnmodifiedSince != null)
{
conditions.Append(nameof(IfUnmodifiedSince)).Append('=').Append(IfUnmodifiedSince).Append(';');
}
if (LeaseId != null)
{
conditions.Append(nameof(LeaseId)).Append('=').Append(LeaseId).Append(';');
}
}
}
}