| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | |
|
| | 6 | | namespace Azure.Iot.Hub.Service |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Helper functions for using the <see cref="IfMatchPrecondition"/> enum. |
| | 10 | | /// </summary> |
| | 11 | | internal static class IfMatchPreconditionExtensions |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Get the ifMatch header value for an HTTP request that targets a particular service resource. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="precondition">The user supplied if match precondition.</param> |
| | 17 | | /// <param name="ETag">The ETag of the resource that the HTTP request is targeting.</param> |
| | 18 | | /// <returns>The ifMatch header value.</returns> |
| | 19 | | internal static string GetIfMatchHeaderValue(IfMatchPrecondition precondition, string ETag) |
| | 20 | | { |
| 228 | 21 | | return precondition switch |
| 228 | 22 | | { |
| 380 | 23 | | IfMatchPrecondition.IfMatch => $"\"{ETag}\"", |
| 304 | 24 | | IfMatchPrecondition.UnconditionalIfMatch => "*", |
| 0 | 25 | | _ => null, |
| 228 | 26 | | }; |
| | 27 | | } |
| | 28 | | } |
| | 29 | | } |