| | | 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 | | /// An action that will be executed. |
| | | 11 | | /// </summary> |
| | | 12 | | public readonly struct CertificatePolicyAction : IEquatable<CertificatePolicyAction> |
| | | 13 | | { |
| | | 14 | | internal const string AutoRenewValue = "AutoRenew"; |
| | | 15 | | internal const string EmailContactsValue = "EmailContacts"; |
| | | 16 | | |
| | | 17 | | private readonly string _value; |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Initializes a new instance of the <see cref="CertificatePolicyAction"/> structure. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="value">The string value of the instance.</param> |
| | | 23 | | public CertificatePolicyAction(string value) |
| | | 24 | | { |
| | 74 | 25 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| | 74 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets a <see cref="CertificatePolicyAction"/> that will auto-renew a certificate. |
| | | 30 | | /// </summary> |
| | 0 | 31 | | public static CertificatePolicyAction AutoRenew { get; } = new CertificatePolicyAction(AutoRenewValue); |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets a <see cref="CertificatePolicyAction"/> action that will email certificate contacts. |
| | | 35 | | /// </summary> |
| | 4 | 36 | | public static CertificatePolicyAction EmailContacts { get; } = new CertificatePolicyAction(EmailContactsValue); |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Determines if two <see cref="CertificatePolicyAction"/> values are the same. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <param name="left">The first <see cref="CertificatePolicyAction"/> to compare.</param> |
| | | 42 | | /// <param name="right">The second <see cref="CertificatePolicyAction"/> to compare.</param> |
| | | 43 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| | 0 | 44 | | public static bool operator ==(CertificatePolicyAction left, CertificatePolicyAction right) => left.Equals(right |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Determines if two <see cref="CertificatePolicyAction"/> values are different. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <param name="left">The first <see cref="CertificatePolicyAction"/> to compare.</param> |
| | | 50 | | /// <param name="right">The second <see cref="CertificatePolicyAction"/> to compare.</param> |
| | | 51 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| | 0 | 52 | | public static bool operator !=(CertificatePolicyAction left, CertificatePolicyAction right) => !left.Equals(righ |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Converts a string to a <see cref="CertificatePolicyAction"/>. |
| | | 56 | | /// </summary> |
| | | 57 | | /// <param name="value">The string value to convert.</param> |
| | 70 | 58 | | public static implicit operator CertificatePolicyAction(string value) => new CertificatePolicyAction(value); |
| | | 59 | | |
| | | 60 | | /// <inheritdoc/> |
| | | 61 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 62 | | public override bool Equals(object obj) => obj is CertificatePolicyAction other && Equals(other); |
| | | 63 | | |
| | | 64 | | /// <inheritdoc/> |
| | 2 | 65 | | public bool Equals(CertificatePolicyAction other) => string.Equals(_value, other._value, StringComparison.Ordina |
| | | 66 | | |
| | | 67 | | /// <inheritdoc/> |
| | | 68 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 69 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | | 70 | | |
| | | 71 | | /// <inheritdoc/> |
| | 2 | 72 | | public override string ToString() => _value; |
| | | 73 | | } |
| | | 74 | | } |