| | 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 type of entities the namespace can contain. |
| | 11 | | /// </summary> |
| | 12 | | internal readonly struct NamespaceType : IEquatable<NamespaceType> |
| | 13 | | { |
| | 14 | | internal const string MessagingValue = "Messaging"; |
| | 15 | | internal const string MixedValue = "Mixed"; |
| | 16 | |
|
| | 17 | | private readonly string _value; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Initializes a new instance of the <see cref="NamespaceType"/> structure. |
| | 21 | | /// </summary> |
| | 22 | | /// <param name="value">The string value of the instance.</param> |
| | 23 | | public NamespaceType(string value) |
| | 24 | | { |
| 8 | 25 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| 8 | 26 | | } |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// Namespace contains service bus entities (queues, topics). |
| | 30 | | /// </summary> |
| 6 | 31 | | public static NamespaceType Messaging { get; } = new NamespaceType(MessagingValue); |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Supported only for backward compatibility. |
| | 35 | | /// Namespace can contain mixture of messaging entities and notification hubs. |
| | 36 | | /// </summary> |
| 0 | 37 | | public static NamespaceType Mixed { get; } = new NamespaceType(MixedValue); |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Determines if two <see cref="NamespaceType"/> values are the same. |
| | 41 | | /// </summary> |
| | 42 | | /// <param name="left">The first <see cref="NamespaceType"/> to compare.</param> |
| | 43 | | /// <param name="right">The second <see cref="NamespaceType"/> to compare.</param> |
| | 44 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| 0 | 45 | | public static bool operator ==(NamespaceType left, NamespaceType right) => left.Equals(right); |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Determines if two <see cref="NamespaceType"/> values are different. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="left">The first <see cref="NamespaceType"/> to compare.</param> |
| | 51 | | /// <param name="right">The second <see cref="NamespaceType"/> to compare.</param> |
| | 52 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| 0 | 53 | | public static bool operator !=(NamespaceType left, NamespaceType right) => !left.Equals(right); |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Converts a string to a <see cref="NamespaceType"/>. |
| | 57 | | /// </summary> |
| | 58 | | /// <param name="value">The string value to convert.</param> |
| 4 | 59 | | public static implicit operator NamespaceType(string value) => new NamespaceType(value); |
| | 60 | |
|
| | 61 | | /// <inheritdoc/> |
| | 62 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 63 | | public override bool Equals(object obj) => obj is NamespaceType other && Equals(other); |
| | 64 | |
|
| | 65 | | /// <inheritdoc/> |
| 4 | 66 | | public bool Equals(NamespaceType other) => string.Equals(_value, other._value, StringComparison.Ordinal); |
| | 67 | |
|
| | 68 | | /// <inheritdoc/> |
| | 69 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 70 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | 71 | |
|
| | 72 | | /// <inheritdoc/> |
| 0 | 73 | | public override string ToString() => _value; |
| | 74 | | } |
| | 75 | | } |