Пример #1
0
        private IMediator BuildMediator(IDependencyScope scope = null)
        {
            var commandReceivePipeConfigurator = new CommandReceivePipeConfigurator(MessageHandlerRegistry, scope);

            _commandReceivePipeConfiguratorAction?.Invoke(commandReceivePipeConfigurator);
            var commandReceivePipe = commandReceivePipeConfigurator.Build();

            var eventReceivePipeConfigurator = new EventReceivePipeConfigurator(MessageHandlerRegistry, scope);

            _eventReceivePipeConfiguratorAction?.Invoke(eventReceivePipeConfigurator);
            var eventReceivePipe = eventReceivePipeConfigurator.Build();


            var requestPipeConfigurator = new RequestPipeConfigurator(MessageHandlerRegistry, scope);

            _requestPipeConfiguratorAction?.Invoke(requestPipeConfigurator);
            var requestPipe = requestPipeConfigurator.Build();

            var publishPipeConfigurator = new PublishPipeConfigurator(scope);

            _publishPipeConfiguratorAction?.Invoke(publishPipeConfigurator);
            var publishPipe = publishPipeConfigurator.Build();

            var globalPipeConfigurator = new GlobalRececivePipeConfigurator(scope);

            _globalReceivePipeConfiguratorAction?.Invoke(globalPipeConfigurator);
            var globalReceivePipe = globalPipeConfigurator.Build();

            return(new Mediator(commandReceivePipe, eventReceivePipe, requestPipe, publishPipe, globalReceivePipe, scope));
        }
Пример #2
0
        public IMediator Build()
        {
            IGlobalReceivePipe <IReceiveContext <IMessage> >  globalReceivePipe;
            ICommandReceivePipe <IReceiveContext <ICommand> > commandReceivePipe;
            IEventReceivePipe <IReceiveContext <IEvent> >     eventReceivePipe;
            IRequestReceivePipe <IReceiveContext <IRequest> > requestPipe;
            IPublishPipe <IPublishContext <IEvent> >          publishPipe;

            var commandReceivePipeConfigurator = new CommandReceivePipeConfigurator();

            if (_commandReceivePipeConfiguratorAction == null)
            {
                commandReceivePipe = commandReceivePipeConfigurator.Build();
            }
            else
            {
                _commandReceivePipeConfiguratorAction(commandReceivePipeConfigurator);
                commandReceivePipe = commandReceivePipeConfigurator.Build();
            }

            var eventReceivePipeConfigurator = new EventReceivePipeConfigurator();

            if (_eventReceivePipeConfiguratorAction == null)
            {
                eventReceivePipe = eventReceivePipeConfigurator.Build();
            }
            else
            {
                _eventReceivePipeConfiguratorAction(eventReceivePipeConfigurator);
                eventReceivePipe = eventReceivePipeConfigurator.Build();
            }


            var requestPipeConfigurator = new RequestPipeConfigurator();

            if (_requestPipeConfiguratorAction == null)
            {
                requestPipe = requestPipeConfigurator.Build();
            }
            else
            {
                _requestPipeConfiguratorAction(requestPipeConfigurator);
                requestPipe = requestPipeConfigurator.Build();
            }

            var publishPipeConfigurator = new PublishPipeConfigurator();

            if (_publishPipeConfiguratorAction == null)
            {
                publishPipe = publishPipeConfigurator.Build();
            }
            else
            {
                _publishPipeConfiguratorAction(publishPipeConfigurator);
                publishPipe = publishPipeConfigurator.Build();
            }

            var globalPipeConfigurator = new GlobalRececivePipeConfigurator();

            if (_globalReceivePipeConfiguratorAction == null)
            {
                globalReceivePipe = globalPipeConfigurator.Build();
            }
            else
            {
                _globalReceivePipeConfiguratorAction(globalPipeConfigurator);
                globalReceivePipe = globalPipeConfigurator.Build();
            }

            return(new Mediator(commandReceivePipe, eventReceivePipe, requestPipe, publishPipe, globalReceivePipe));
        }