| | 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.Messaging.ServiceBus.Management |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// The status of the messaging entity. |
| | 11 | | /// </summary> |
| | 12 | | public readonly struct EntityStatus : IEquatable<EntityStatus> |
| | 13 | | { |
| | 14 | | internal const string ActiveValue = "Active"; |
| | 15 | | internal const string DisabledValue = "Disabled"; |
| | 16 | | internal const string SendDisabledValue = "SendDisabled"; |
| | 17 | | internal const string ReceiveDisabledValue = "ReceiveDisabled"; |
| | 18 | |
|
| | 19 | | private readonly string _value; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Initializes a new instance of the <see cref="EntityStatus"/> structure. |
| | 23 | | /// </summary> |
| | 24 | | /// <param name="value">The string value of the instance.</param> |
| | 25 | | public EntityStatus(string value) |
| | 26 | | { |
| 144 | 27 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| 144 | 28 | | } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// The status of the messaging entity is active. |
| | 32 | | /// </summary> |
| 404 | 33 | | public static EntityStatus Active { get; } = new EntityStatus(ActiveValue); |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// The status of the messaging entity is active. |
| | 37 | | /// </summary> |
| 10 | 38 | | public static EntityStatus Disabled { get; } = new EntityStatus(DisabledValue); |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// The sending status of the messaging entity is disabled. |
| | 42 | | /// </summary> |
| 0 | 43 | | public static EntityStatus SendDisabled { get; } = new EntityStatus(SendDisabledValue); |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// The receiving status of the messaging entity is disabled. |
| | 47 | | /// </summary> |
| 0 | 48 | | public static EntityStatus ReceiveDisabled { get; } = new EntityStatus(ReceiveDisabledValue); |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Determines if two <see cref="EntityStatus"/> values are the same. |
| | 52 | | /// </summary> |
| | 53 | | /// <param name="left">The first <see cref="EntityStatus"/> to compare.</param> |
| | 54 | | /// <param name="right">The second <see cref="EntityStatus"/> to compare.</param> |
| | 55 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| 0 | 56 | | public static bool operator ==(EntityStatus left, EntityStatus right) => left.Equals(right); |
| | 57 | |
|
| | 58 | | /// <summary> |
| | 59 | | /// Determines if two <see cref="EntityStatus"/> values are different. |
| | 60 | | /// </summary> |
| | 61 | | /// <param name="left">The first <see cref="EntityStatus"/> to compare.</param> |
| | 62 | | /// <param name="right">The second <see cref="EntityStatus"/> to compare.</param> |
| | 63 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| 0 | 64 | | public static bool operator !=(EntityStatus left, EntityStatus right) => !left.Equals(right); |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Converts a string to a <see cref="EntityStatus"/>. |
| | 68 | | /// </summary> |
| | 69 | | /// <param name="value">The string value to convert.</param> |
| 136 | 70 | | public static implicit operator EntityStatus(string value) => new EntityStatus(value); |
| | 71 | |
|
| | 72 | | /// <inheritdoc/> |
| | 73 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 74 | | public override bool Equals(object obj) => obj is EntityStatus other && Equals(other); |
| | 75 | |
|
| | 76 | | /// <inheritdoc/> |
| 44 | 77 | | public bool Equals(EntityStatus other) => string.Equals(_value, other._value, StringComparison.Ordinal); |
| | 78 | |
|
| | 79 | | /// <inheritdoc/> |
| | 80 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 81 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | 82 | |
|
| | 83 | | /// <inheritdoc/> |
| 116 | 84 | | public override string ToString() => _value; |
| | 85 | | } |
| | 86 | | } |