| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | namespace Azure.Storage.Cryptography.Models |
| | | 5 | | { |
| | | 6 | | internal static class ClientSideEncryptionVersionExtensions |
| | | 7 | | { |
| | | 8 | | public static class ClientSideEncryptionVersionString |
| | | 9 | | { |
| | | 10 | | public const string V1_0 = "1.0"; |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | public static string Serialize(this ClientSideEncryptionVersion version) |
| | | 14 | | { |
| | | 15 | | switch (version) |
| | | 16 | | { |
| | | 17 | | case ClientSideEncryptionVersion.V1_0: |
| | 0 | 18 | | return ClientSideEncryptionVersionString.V1_0; |
| | | 19 | | default: |
| | | 20 | | // sanity check; serialize is in this file to make it easy to add the serialization cases |
| | 0 | 21 | | throw Errors.ClientSideEncryption.ClientSideEncryptionVersionNotSupported(); |
| | | 22 | | } |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | public static ClientSideEncryptionVersion ToClientSideEncryptionVersion(this string versionString) |
| | | 26 | | { |
| | | 27 | | switch (versionString) |
| | | 28 | | { |
| | | 29 | | case ClientSideEncryptionVersionString.V1_0: |
| | 0 | 30 | | return ClientSideEncryptionVersion.V1_0; |
| | | 31 | | default: |
| | | 32 | | // This library doesn't support the stated encryption version |
| | 0 | 33 | | throw Errors.ClientSideEncryption.ClientSideEncryptionVersionNotSupported(versionString); |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |
| | | 37 | | } |