public void Execute(BatchCommand command)
 {
     foreach (var cmd in command.Commands)
     {
         _dispatcher.Submit((dynamic)cmd);
     }
 }
        public async Task StartAsync()
        {
            await Task.Run(() =>
            {
                _client.OnMessage(receivedMessage =>
                {
                    try
                    {
                        var type = Type.GetType(receivedMessage.Properties["Type"].ToString());

                        var cmd = JsonConvert.DeserializeObject(receivedMessage.GetBody <string>(), type);

                        _dispatcher.Submit(Convert.ChangeType(cmd, type));
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Error while handling command, ex={ex}", ex.BuildExceptionInfo());
                    }
                });

                _stopEvent.WaitOne();
            });
        }
Beispiel #3
0
        public void AddPackage(PackageDto package)
        {
            var command = new AddPackageCommand(package);

            _commandDispatcher.Submit(command);
        }