| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Globalization; |
| | | 6 | | |
| | | 7 | | namespace Azure.Messaging.ServiceBus.Core |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// The set of extension methods for the <see cref="ServiceBusTransportType" /> enumeration. |
| | | 11 | | /// </summary> |
| | | 12 | | /// |
| | | 13 | | internal static class TransportTypeExtensions |
| | | 14 | | { |
| | | 15 | | /// <summary>The URI scheme used for an AMQP-based connection.</summary> |
| | | 16 | | private const string AmqpUriScheme = "amqps"; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Determines the URI scheme to be used for the given connection type. |
| | | 20 | | /// </summary> |
| | | 21 | | /// |
| | | 22 | | /// <param name="instance">The instance that this method was invoked on.</param> |
| | | 23 | | /// |
| | | 24 | | /// <returns>The scheme that should be used for the given connection type when forming an associated URI.</retur |
| | | 25 | | /// |
| | | 26 | | public static string GetUriScheme(this ServiceBusTransportType instance) |
| | | 27 | | { |
| | | 28 | | switch (instance) |
| | | 29 | | { |
| | | 30 | | case ServiceBusTransportType.AmqpTcp: |
| | | 31 | | case ServiceBusTransportType.AmqpWebSockets: |
| | 122 | 32 | | return AmqpUriScheme; |
| | | 33 | | |
| | | 34 | | default: |
| | 0 | 35 | | throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidTransportType |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Determines whether the specified transport makes use of web sockets. |
| | | 41 | | /// </summary> |
| | | 42 | | /// |
| | | 43 | | /// <param name="instance">The instance that this method was invoked on.</param> |
| | | 44 | | /// |
| | | 45 | | /// <returns><c>true</c> if the transport uses web sockets; otherwise, <c>false</c>.</returns> |
| | | 46 | | /// |
| | 52 | 47 | | public static bool IsWebSocketTransport(this ServiceBusTransportType instance) => (instance == ServiceBusTranspo |
| | | 48 | | } |
| | | 49 | | } |