| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | |
| | | 7 | | namespace Azure.Security.KeyVault.Certificates |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Content type of the certificate when downloaded from getSecret. |
| | | 11 | | /// </summary> |
| | | 12 | | public readonly struct CertificateContentType : IEquatable<CertificateContentType> |
| | | 13 | | { |
| | | 14 | | private readonly string _value; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="CertificateContentType"/> structure. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="value">The string value of the instance.</param> |
| | | 20 | | public CertificateContentType(string value) |
| | | 21 | | { |
| | 74 | 22 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| | 74 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets a value indicating that content is downloaded in pkcs12 (PFX) format. |
| | | 27 | | /// </summary> |
| | 76 | 28 | | public static CertificateContentType Pkcs12 { get; } = new CertificateContentType("application/x-pkcs12"); |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets a value indicating that content is downloaded in PEM format. |
| | | 32 | | /// </summary> |
| | 18 | 33 | | public static CertificateContentType Pem { get; } = new CertificateContentType("application/x-pem-file"); |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Determines if two <see cref="CertificateContentType"/> values are the same. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <param name="left">The first <see cref="CertificateContentType"/> to compare.</param> |
| | | 39 | | /// <param name="right">The second <see cref="CertificateContentType"/> to compare.</param> |
| | | 40 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| | 8 | 41 | | public static bool operator ==(CertificateContentType left, CertificateContentType right) => left.Equals(right); |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Determines if two <see cref="CertificateContentType"/> values are different. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="left">The first <see cref="CertificateContentType"/> to compare.</param> |
| | | 47 | | /// <param name="right">The second <see cref="CertificateContentType"/> to compare.</param> |
| | | 48 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| | 0 | 49 | | public static bool operator !=(CertificateContentType left, CertificateContentType right) => !left.Equals(right) |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Converts a string to a <see cref="CertificateContentType"/>. |
| | | 53 | | /// </summary> |
| | | 54 | | /// <param name="value">The string value to convert.</param> |
| | 70 | 55 | | public static implicit operator CertificateContentType(string value) => new CertificateContentType(value); |
| | | 56 | | |
| | | 57 | | /// <inheritdoc/> |
| | | 58 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 59 | | public override bool Equals(object obj) => obj is CertificateContentType other && Equals(other); |
| | | 60 | | |
| | | 61 | | /// <inheritdoc/> |
| | 14 | 62 | | public bool Equals(CertificateContentType other) => string.Equals(_value, other._value, StringComparison.Ordinal |
| | | 63 | | |
| | | 64 | | /// <inheritdoc/> |
| | | 65 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 66 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | | 67 | | |
| | | 68 | | /// <inheritdoc/> |
| | 70 | 69 | | public override string ToString() => _value; |
| | | 70 | | } |
| | | 71 | | } |