| | 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 | | /// Specifies the SKU/tier of the messaging namespace. |
| | 11 | | /// </summary> |
| | 12 | | public readonly struct MessagingSku : IEquatable<MessagingSku> |
| | 13 | | { |
| | 14 | | internal const string BasicValue = "Basic"; |
| | 15 | | internal const string StandardValue = "Standard"; |
| | 16 | | internal const string PremiumValue = "Premium"; |
| | 17 | |
|
| | 18 | | private readonly string _value; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Initializes a new instance of the <see cref="MessagingSku"/> structure. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="value">The string value of the instance.</param> |
| | 24 | | public MessagingSku(string value) |
| | 25 | | { |
| 4 | 26 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| 4 | 27 | | } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Basic namespace. Shared Resource. Only queues are available. |
| | 31 | | /// </summary> |
| 0 | 32 | | public static MessagingSku Basic { get; } = new MessagingSku(BasicValue); |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Standard namespace. Shared Resource. Queues and topics. |
| | 36 | | /// </summary> |
| 0 | 37 | | public static MessagingSku Standard { get; } = new MessagingSku(StandardValue); |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Premium namespace. Dedicated Resource. Queues and topics. |
| | 41 | | /// </summary> |
| 0 | 42 | | public static MessagingSku Premium { get; } = new MessagingSku(PremiumValue); |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Determines if two <see cref="MessagingSku"/> values are the same. |
| | 46 | | /// </summary> |
| | 47 | | /// <param name="left">The first <see cref="MessagingSku"/> to compare.</param> |
| | 48 | | /// <param name="right">The second <see cref="MessagingSku"/> to compare.</param> |
| | 49 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| 0 | 50 | | public static bool operator ==(MessagingSku left, MessagingSku right) => left.Equals(right); |
| | 51 | |
|
| | 52 | | /// <summary> |
| | 53 | | /// Determines if two <see cref="MessagingSku"/> values are different. |
| | 54 | | /// </summary> |
| | 55 | | /// <param name="left">The first <see cref="MessagingSku"/> to compare.</param> |
| | 56 | | /// <param name="right">The second <see cref="MessagingSku"/> to compare.</param> |
| | 57 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| 0 | 58 | | public static bool operator !=(MessagingSku left, MessagingSku right) => !left.Equals(right); |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Converts a string to a <see cref="MessagingSku"/>. |
| | 62 | | /// </summary> |
| | 63 | | /// <param name="value">The string value to convert.</param> |
| 4 | 64 | | public static implicit operator MessagingSku(string value) => new MessagingSku(value); |
| | 65 | |
|
| | 66 | | /// <inheritdoc/> |
| | 67 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 68 | | public override bool Equals(object obj) => obj is MessagingSku other && Equals(other); |
| | 69 | |
|
| | 70 | | /// <inheritdoc/> |
| 0 | 71 | | public bool Equals(MessagingSku other) => string.Equals(_value, other._value, StringComparison.Ordinal); |
| | 72 | |
|
| | 73 | | /// <inheritdoc/> |
| | 74 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 75 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | 76 | |
|
| | 77 | | /// <inheritdoc/> |
| 0 | 78 | | public override string ToString() => _value; |
| | 79 | | } |
| | 80 | | } |