| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Text; |
| | 6 | | using Azure.Storage.Blobs.Models; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Blobs.Models |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Specifies blob lease access conditions for a container or blob. |
| | 12 | | /// </summary> |
| | 13 | | public class BlobRequestConditions : BlobLeaseRequestConditions |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Optionally limit requests to resources with an active lease |
| | 17 | | /// matching this Id. |
| | 18 | | /// </summary> |
| 5116 | 19 | | public string LeaseId { get; set; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Converts the value of the current RequestConditions object to |
| | 23 | | /// its equivalent string representation. |
| | 24 | | /// </summary> |
| | 25 | | /// <returns> |
| | 26 | | /// A string representation of the RequestConditions. |
| | 27 | | /// </returns> |
| | 28 | | public override string ToString() |
| | 29 | | { |
| 0 | 30 | | StringBuilder conditions = new StringBuilder(); |
| 0 | 31 | | conditions.Append('[').Append(GetType().Name); |
| 0 | 32 | | AddConditions(conditions); |
| 0 | 33 | | if (conditions[conditions.Length - 1] == ';') |
| | 34 | | { |
| 0 | 35 | | conditions[conditions.Length - 1] = ']'; |
| | 36 | | } |
| | 37 | | else |
| | 38 | | { |
| 0 | 39 | | conditions.Append(']'); |
| | 40 | | } |
| 0 | 41 | | return conditions.ToString(); |
| | 42 | | } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Collect any request conditions. Conditions should be separated by |
| | 46 | | /// a semicolon. |
| | 47 | | /// </summary> |
| | 48 | | /// <param name="conditions">The collected conditions.</param> |
| | 49 | | internal virtual void AddConditions(StringBuilder conditions) |
| | 50 | | { |
| 0 | 51 | | if (IfMatch != null) |
| | 52 | | { |
| 0 | 53 | | conditions.Append(nameof(IfMatch)).Append('=').Append(IfMatch).Append(';'); |
| | 54 | | } |
| | 55 | |
|
| 0 | 56 | | if (IfNoneMatch != null) |
| | 57 | | { |
| 0 | 58 | | conditions.Append(nameof(IfNoneMatch)).Append('=').Append(IfNoneMatch).Append(';'); |
| | 59 | | } |
| | 60 | |
|
| 0 | 61 | | if (IfModifiedSince != null) |
| | 62 | | { |
| 0 | 63 | | conditions.Append(nameof(IfModifiedSince)).Append('=').Append(IfModifiedSince).Append(';'); |
| | 64 | | } |
| | 65 | |
|
| 0 | 66 | | if (IfUnmodifiedSince != null) |
| | 67 | | { |
| 0 | 68 | | conditions.Append(nameof(IfUnmodifiedSince)).Append('=').Append(IfUnmodifiedSince).Append(';'); |
| | 69 | | } |
| | 70 | |
|
| 0 | 71 | | if (LeaseId != null) |
| | 72 | | { |
| 0 | 73 | | conditions.Append(nameof(LeaseId)).Append('=').Append(LeaseId).Append(';'); |
| | 74 | | } |
| | 75 | |
|
| 0 | 76 | | if (TagConditions != null) |
| | 77 | | { |
| 0 | 78 | | conditions.Append(nameof(TagConditions)).Append('=').Append(TagConditions).Append(';'); |
| | 79 | | } |
| 0 | 80 | | } |
| | 81 | | } |
| | 82 | | } |