public CompiledRouterConnectionSettings(RouterConnectionSettingsCollection collection)
    {
        foreach (var router in collection.Connections)
        {
            if (defaultRouter == null)
            {
                defaultRouter = router.RouterAddress;
            }

            if (router.EnableAutoSubscribe)
            {
                autoSubscribeRouters.Add(router.RouterAddress);
            }

            foreach (var publisherEntry in router.PublisherTable)
            {
                if (eventRouting.TryGetValue(publisherEntry.Key, out var publisherInfo))
                {
                    throw new Exception($"Event {publisherEntry.Key} is already associated with endpoint {publisherInfo.Router} via router {publisherInfo.Router}.");
                }
                eventRouting[publisherEntry.Key] = new DestinationInfo(publisherEntry.Value, router.RouterAddress);
            }

            foreach (var receiverEntry in router.SendRouteTable)
            {
                if (commandRouting.TryGetValue(receiverEntry.Key, out var receiverInfo))
                {
                    throw new Exception($"Message {receiverEntry.Key} is already associated with endpoint {receiverInfo.Router} via router {receiverInfo.Router}.");
                }
                commandRouting[receiverEntry.Key] = new DestinationInfo(receiverEntry.Value, router.RouterAddress);
            }
        }
    }
        static RouterConnectionSettings ConnectToRouterImpl(RoutingSettings routingSettings, string routerAddress, bool enableAutoSubscribe, bool enableAutoPublish)
        {
            var settingsHolder = routingSettings.GetSettings();

            settingsHolder.EnableFeatureByDefault(typeof(RouterConnectionFeature));

            if (!settingsHolder.TryGet(out RouterConnectionSettingsCollection connectionSettings))
            {
                connectionSettings = new RouterConnectionSettingsCollection();
                settingsHolder.Set(connectionSettings);
            }

            return(connectionSettings.GetOrCreate(routerAddress, enableAutoSubscribe, enableAutoPublish));
        }