예제 #1
0
        private async Task DoInitialization()
        {
            await _messageEndPoint.RegisterAsync(new DefaultHandlerFactory <CommandMessageBroker>());

            await _messageEndPoint.RegisterAsync <RegisterCommandForwarding>(new DefaultHandlerFactory <CommandMessageBroker>());

            await _messageEndPoint.RegisterAsync <UnregisterCommandForwarding>(new DefaultHandlerFactory <CommandMessageBroker>());

            await _messageEndPoint.RegisterAsync(new DefaultHandlerFactory <QueryMessageBroker>());

            await _messageEndPoint.RegisterAsync <RegisterQueryForwarding>(new DefaultHandlerFactory <QueryMessageBroker>());

            await _messageEndPoint.RegisterAsync <UnregisterQueryForwarding>(new DefaultHandlerFactory <QueryMessageBroker>());

            await _messageEndPoint.RegisterAsync <RegisterEventForwarding>(new DefaultHandlerFactory <EventMessageBroker>());

            await _messageEndPoint.RegisterAsync <UnregisterEventForwarding>(new DefaultHandlerFactory <EventMessageBroker>());

            await _messageEndPoint.RegisterAsync <DispatchEvent>(new DefaultHandlerFactory <EventMessageBroker>());

            await _messageEndPoint.Initialization;

            var setupMessage = new SetupModule();

            await _messageEndPoint.SendAsync(setupMessage);
        }
예제 #2
0
        public Task RegisterForwardingAsync <TQuery>()
        {
            var message = new RegisterQueryForwarding(typeof(TQuery));

            Console.WriteLine($"Sending 'RegisterQueryForwarding' for query type '{message.QueryType.FullName}'.");

            return(_messageEndPoint.SendAsync(message));
        }
예제 #3
0
        public Task RegisterForwardingAsync <TCommand>()
        {
            var message = new RegisterCommandForwarding(typeof(TCommand));

            Console.WriteLine($"Sending 'RegisterCommandForwarding' for command type '{message.CommandType.FullName}'.");

            return(_messageEndPoint.SendAsync(message));
        }
예제 #4
0
        public Task RegisterForwardingAsync <TEvent>()
        {
            var message = new RegisterEventForwarding(typeof(TEvent));

            Console.WriteLine($"Sending 'RegisterEventForwarding' for event type '{message.EventType.FullName}'.");

            return(_messageEndPoint.SendAsync(message));
        }
예제 #5
0
        public async Task <IEventResult> HandleAsync(TEvent evt)
        {
            if (evt == null)
            {
                throw new ArgumentNullException(nameof(evt));
            }

            var message = new DispatchEvent(typeof(TEvent), evt);

            Console.WriteLine($"Sending 'DispatchEvent' for event type '{message.EventType.FullName}' with event '{message.Event}'.");

            var answer = await _messageEndPoint.SendAsync <DispatchEvent, EventDispatchResult>(message);

            return(answer.EventResult);
        }
예제 #6
0
        public async Task <IQueryResult> HandleAsync(TQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var message = new DispatchQuery(typeof(TQuery), query);

            Console.WriteLine($"Sending 'DispatchQuery' for query type '{message.QueryType.FullName}' with query '{message.Query}'.");

            var answer = await _messageEndPoint.SendAsync <DispatchQuery, QueryDispatchResult>(message);

            return(answer.QueryResult);
        }
예제 #7
0
        public async Task <ICommandResult> HandleAsync(TCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var message = new DispatchCommand(typeof(TCommand), command);

            Console.WriteLine($"Sending 'DispatchCommand' for command type '{message.CommandType.FullName}' with command '{message.Command}'.");

            var answer = await _messageEndPoint.SendAsync <DispatchCommand, CommandDispatchResult>(message);

            return(answer.CommandResult);
        }