public static ReceiveSettings GetReceiveSettings(this Uri address)
        {
            var hostAddress     = new RabbitMqHostAddress(address);
            var endpointAddress = new RabbitMqEndpointAddress(hostAddress, address);

            var topologyConfiguration = new RabbitMqTopologyConfiguration(RabbitMqBusFactory.MessageTopology);
            var endpointConfiguration = new RabbitMqEndpointConfiguration(topologyConfiguration);
            var settings = new RabbitMqReceiveSettings(endpointConfiguration, endpointAddress.Name, endpointAddress.ExchangeType,
                                                       endpointAddress.Durable, endpointAddress.AutoDelete)
            {
                QueueName = endpointAddress.Name,
                Exclusive = endpointAddress.AutoDelete && !endpointAddress.Durable
            };

            if (hostAddress.Prefetch.HasValue)
            {
                settings.PrefetchCount = hostAddress.Prefetch.Value;
            }

            if (hostAddress.TimeToLive.HasValue)
            {
                settings.QueueArguments.Add(Headers.XMessageTTL, hostAddress.TimeToLive.Value.ToString("F0", CultureInfo.InvariantCulture));
            }

            return(settings);
        }
        internal static ConfigurationHostSettings GetConfigurationHostSettings(this Uri address)
        {
            var hostAddress = new RabbitMqHostAddress(address);

            var hostSettings = new ConfigurationHostSettings
            {
                Host        = hostAddress.Host,
                VirtualHost = hostAddress.VirtualHost,
                Username    = "",
                Password    = "",
            };

            if (hostAddress.Port.HasValue)
            {
                hostSettings.Port = hostAddress.Port.Value;
            }

            if (!string.IsNullOrEmpty(address.UserInfo))
            {
                string[] parts = address.UserInfo.Split(':');
                hostSettings.Username = parts[0];

                if (parts.Length >= 2)
                {
                    hostSettings.Password = parts[1];
                }
            }

            hostSettings.Heartbeat = hostAddress.Heartbeat ?? (ushort)0;

            return(hostSettings);
        }
        internal static ConfigurationHostSettings GetConfigurationHostSettings(this Uri address)
        {
            var hostAddress = new RabbitMqHostAddress(address);

            var hostSettings = new ConfigurationHostSettings
            {
                Host        = hostAddress.Host,
                VirtualHost = hostAddress.VirtualHost,
                Username    = "",
                Password    = ""
            };

            if (hostAddress.Port.HasValue)
            {
                hostSettings.Port = hostAddress.Port.Value;
            }

            if (!string.IsNullOrEmpty(address.UserInfo))
            {
                var parts = address.UserInfo.Split(':');
                hostSettings.Username = UriDecode(parts[0]);

                if (parts.Length >= 2)
                {
                    hostSettings.Password = UriDecode(parts[1]);
                }
            }

            hostSettings.Heartbeat = TimeSpan.FromSeconds(hostAddress.Heartbeat ?? 0);

            return(hostSettings);
        }
        static void ParseLeft(Uri address, out string scheme, out string host, out int?port, out string virtualHost)
        {
            var hostAddress = new RabbitMqHostAddress(address);

            scheme      = hostAddress.Scheme;
            host        = hostAddress.Host;
            port        = hostAddress.Port;
            virtualHost = hostAddress.VirtualHost;
        }
        public static ReceiveSettings GetReceiveSettings(this Uri address)
        {
            var hostAddress     = new RabbitMqHostAddress(address);
            var endpointAddress = new RabbitMqEndpointAddress(hostAddress, address);

            ReceiveSettings settings = new RabbitMqReceiveSettings(endpointAddress.Name, endpointAddress.ExchangeType, endpointAddress.Durable,
                                                                   endpointAddress.AutoDelete)
            {
                QueueName     = endpointAddress.Name,
                PrefetchCount = hostAddress.Prefetch ?? (ushort)(Environment.ProcessorCount * 2),
                Exclusive     = endpointAddress.AutoDelete && !endpointAddress.Durable
            };

            if (hostAddress.TimeToLive.HasValue)
            {
                settings.QueueArguments.Add(Headers.XMessageTTL, hostAddress.TimeToLive.Value.ToString("F0", CultureInfo.InvariantCulture));
            }

            return(settings);
        }