public static IMessageForwardingConfiguration Configuration()
        {
            var section       = ConfigurationSectionProvider.Open <MessageForwardingSection>("shuttle", "messageForwarding");
            var configuration = new MessageForwardingConfiguration();

            if (section?.ForwardingRoutes == null)
            {
                return(configuration);
            }

            var factory = new MessageRouteSpecificationFactory();

            foreach (MessageRouteElement mapElement in section.ForwardingRoutes)
            {
                var map = configuration.MessageRoutes.Find(mapElement.Uri);

                if (map == null)
                {
                    map = new MessageRoute(new Uri(mapElement.Uri));

                    configuration.MessageRoutes.Add(map);
                }

                foreach (SpecificationElement specificationElement in mapElement)
                {
                    map.AddSpecification(factory.Create(specificationElement.Name, specificationElement.Value));
                }
            }

            return(configuration);
        }
        public void Apply(IServiceBusConfiguration configuration)
        {
            if (ServiceBusConfiguration.ServiceBusSection == null ||
                ServiceBusConfiguration.ServiceBusSection.MessageRoutes == null)
            {
                return;
            }

            var specificationFactory = new MessageRouteSpecificationFactory();
            var provider = configuration.MessageRouteProvider;

            foreach (MessageRouteElement mapElement in ServiceBusConfiguration.ServiceBusSection.MessageRoutes)
            {
                var messageRoute = provider.Find(mapElement.Uri);

                if (messageRoute == null)
                {
                    messageRoute = new MessageRoute(configuration.QueueManager.GetQueue(mapElement.Uri));

                    provider.Add(messageRoute);
                }

                foreach (SpecificationElement specificationElement in mapElement)
                {
                    messageRoute.AddSpecification(specificationFactory.Create(specificationElement.Name, specificationElement.Value));
                }
            }
        }
        public void Apply(IServiceBusConfiguration configuration)
        {
            if (ServiceBusConfiguration.ServiceBusSection == null ||
                ServiceBusConfiguration.ServiceBusSection.MessageRoutes == null)
            {
                return;
            }

            var specificationFactory = new MessageRouteSpecificationFactory();
            var provider             = configuration.MessageRouteProvider;

            foreach (MessageRouteElement mapElement in ServiceBusConfiguration.ServiceBusSection.MessageRoutes)
            {
                var messageRoute = provider.Find(mapElement.Uri);

                if (messageRoute == null)
                {
                    messageRoute = new MessageRoute(configuration.QueueManager.GetQueue(mapElement.Uri));

                    provider.Add(messageRoute);
                }

                foreach (SpecificationElement specificationElement in mapElement)
                {
                    messageRoute.AddSpecification(specificationFactory.Create(specificationElement.Name, specificationElement.Value));
                }
            }
        }
        internal void Initialize(IServiceBus bus)
        {
            var section = ConfigurationSectionProvider.Open <MessageForwardingSection>("shuttle", "messageForwarding");

            if (section == null || section.ForwardingRoutes == null)
            {
                return;
            }

            var factory = new MessageRouteSpecificationFactory();

            foreach (MessageRouteElement mapElement in section.ForwardingRoutes)
            {
                var map = _messageRoutes.Find(mapElement.Uri);

                if (map == null)
                {
                    map = new MessageRoute(bus.Configuration.QueueManager.GetQueue(mapElement.Uri));

                    _messageRoutes.Add(map);
                }

                foreach (SpecificationElement specificationElement in mapElement)
                {
                    map.AddSpecification(factory.Create(specificationElement.Name, specificationElement.Value));
                }
            }
        }