public static UnsubscribeAction ConnectToRouter <TOutput>(this IPipelineSink <ISendContext> pipeline,
                                                                  IPipelineSink <IBusPublishContext <TOutput> > sink)
            where TOutput : class
        {
            var routerConfigurator = new OutboundMessageRouterConfigurator(pipeline);

            MessageRouter <IBusPublishContext <TOutput> > router = routerConfigurator.FindOrCreate <TOutput>();

            UnsubscribeAction result = router.Connect(sink);

            return(() => result() && (router.SinkCount == 0));
        }
        public CorrelatedMessageRouter <IBusPublishContext <TMessage>, TMessage, TKey> FindOrCreate <TMessage, TKey>()
            where TMessage : class, ICorrelatedBy <TKey>
        {
            var configurator = new OutboundMessageRouterConfigurator(_sink);

            MessageRouter <IBusPublishContext <TMessage> > router = configurator.FindOrCreate <TMessage>();

            var scope = new OutboundCorrelatedMessageRouterConfiguratorScope <TMessage, TKey>();

            _sink.Inspect(scope);

            return(scope.Router ?? ConfigureRouter <TMessage, TKey>(router));
        }