Esempio n. 1
0
        public Task Command <TArguments>(TArguments arguments)
        {
            var handler = commandFactory.Resolve <TArguments>();

            try
            {
                return(handler.Execute(arguments));
            }
            finally
            {
                commandFactory.Release(handler);
            }
        }
Esempio n. 2
0
        public async Task Command <TArguments>(TArguments arguments) where TArguments : ICommand
        {
            var handler = commandHandlerFactory.Resolve <TArguments>();

            try
            {
                await handler.Handle(arguments);
            }
            finally
            {
                commandHandlerFactory.Release(handler);
            }
        }
 public ICommandResult Submit <TCommand>(TCommand command) where TCommand : Commands.ICommand
 {
     try
     {
         var handler = _commandHandlerFactory.Resolve <TCommand>();
         return(handler.Execute(command));
     }
     catch (ComponentNotFoundException cnfex)
     {
         // log here
         throw cnfex;
     }
 }
Esempio n. 4
0
        public async Task Process <TCommand>(ICommandWrapper <TCommand> commandWrapper) where TCommand : ICommand
        {
            var commandHandler = _commandHandlerFactory.Resolve <TCommand>();
            IReadOnlyCollection <IEvent> events;

            try {
                events = await commandHandler.Handle(commandWrapper.Command);
            }
            catch (Exception ex) {
                if (commandWrapper.IsLinkToJob)
                {
                    await _jobHandler.Fail(commandWrapper, ex);
                }
                return;
            }
            if (events.Any())
            {
                await _eventDispatcher.Send(commandWrapper, events);
            }
            else
            {
                await _jobHandler.Done(commandWrapper);
            }
        }
Esempio n. 5
0
        public void Send <TCommand>(TCommand command) where TCommand : ICommand
        {
            var handler = _factory.Resolve <TCommand>();

            handler.Handle(command);
        }
        public async Task <string> ExecuteAsync <T>(T command) where T : ICommand
        {
            var handler = _factory.Resolve <T>();

            return(await handler.ExecuteAsync(command).ConfigureAwait(false));
        }