/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Transports/MassTransit.Azure.ServiceBus.Core/ServiceBusHostAddress.cs
60 строк
2 KB
Chris Patterson
Integration of all external packages into MassTransit, split out into Abstractions, Middleware, and the core MassTransit assembly.
22 янв 2022, 18:24
22 янв 2022, 18:24
b5b4f50
Код
Авторство
О чём код?
namespace MassTransit { using System; using System.Diagnostics; using Internals; [DebuggerDisplay("{" + nameof(DebuggerDisplay) + "}")] public readonly struct ServiceBusHostAddress { public readonly string Scheme; public readonly string Host; public readonly string Scope; public ServiceBusHostAddress(Uri address) { Scheme = default; Host = default; Scope = default; var scheme = address.Scheme.ToLowerInvariant(); switch (scheme) { case "sb": Scheme = address.Scheme; Host = address.Host; ParseLeft(address, out Scheme, out Host, out Scope); break; default: throw new ArgumentException($"The address scheme is not supported: {address.Scheme}", nameof(address)); } } static void ParseLeft(Uri address, out string scheme, out string host, out string scope) { scheme = address.Scheme; host = address.Host; scope = address.ParseHostPath(); } public static implicit operator Uri(in ServiceBusHostAddress address) { var builder = new UriBuilder { Scheme = address.Scheme, Host = address.Host, Path = address.Scope == "/" ? "/" : $"/{Uri.EscapeDataString(address.Scope)}" }; return builder.Uri; } Uri DebuggerDisplay => this; } }