예제 #1
0
        public void Run1()
        {
            Console.WriteLine("Press 'Enter' to send a message to create a new Aggregate.To exit, Ctrl + C");
            Console.ReadLine();

            Bus.Send("ServerQueue", new CommandMessage {
                Payload = new CreateSomeObjectCommand {
                    ObjectId = AggregateId
                }
            });

            string line;

            while ((line = Console.ReadLine()) != null)
            {
                ICommand payload = new DoSomethingCommand {
                    Value = line, ObjectId = AggregateId
                };
                var command = new CommandMessage
                {
                    Payload = payload
                };
                Bus.Send("ServerQueue", command);
            }
        }
예제 #2
0
        public async Task <ICommandResult <string> > Handle(DoSomethingCommand command, CancellationToken cancellationToken)
        {
            await Task.Delay(1000, cancellationToken);

            _log.LogInformation("Thing {Thing} done", command.ThingToDo);

            return(new CommandResult <string>(CommandStatus.Ok, "world!"));
        }
예제 #3
0
        public void ShouldSetOtputIfThePropertyExists()
        {
            var commandWithOutput = new DoSomethingCommand();
            var output            = new MemoryOutput();

            var result = CommandMetaDataHelper.SetOutputProperty(commandWithOutput, output);

            Assert.IsTrue(result);
        }
        public async Task <IActionResult> DoSomething(string id)
        {
            var cmd = new DoSomethingCommand(Guid.Parse(id));

            await _dispatcher.DispatchAsync(cmd);

            await _unitOfWork.CommitAsync();

            return(Ok(cmd));
        }
예제 #5
0
        public async Task <IActionResult> DoSomething(string id)
        {
            var cmd = new DoSomethingCommand(Guid.Parse(id));

            var response = await _dispatcher.DispatchAsync <DoSomethingCommand, DoSomethingResponse>(cmd);

            await _session.CommitAsync();

            return(Ok(response));
        }
예제 #6
0
        public void Handle(DoSomethingCommand message)
        {
            _log.WarnFormat("Handled DoSomethingCommand, message.SagaId={0}, SagaId={1}", message.SagaId, Data.Id);
            Data.SagaId = message.SagaId;

            var forwardSagaMessage = new ForwardSagaMessage {
                SagaId = Data.Id
            };

            _log.WarnFormat("Sending ForwardSagaMessage, SagaId={0}", forwardSagaMessage.SagaId);
            Bus.SendLocal(forwardSagaMessage);
        }
        public void WillSerializeCommands()
        {
            var command = new DoSomethingCommand
                {
                    Name = "Test",
                    NumberOfTimes = 1
                };

            var builder = new StringWriter();
            var sut = new JsonCommandSerializer(builder);

            sut.Inspect(command);

            Console.WriteLine(builder);
        }
예제 #8
0
        public void Handle(ForwardMessage message)
        {
            _log.WarnFormat("Handled ForwardMessage, AccountId={0}, SagaId={1}", message.AccountId, Data.Id);

            var doSomethingCommand = new DoSomethingCommand {
                SagaId = Data.Id
            };

            _log.WarnFormat("Sending DoSomethingCommand, SagaId={0}", doSomethingCommand.SagaId);
            Bus.Send(doSomethingCommand);

            var doSomethingElseCommand = new DoSomethingElseCommand {
                SagaId = Data.Id
            };

            _log.WarnFormat("Sending DoSomethingElseCommand, SagaId={0}", doSomethingElseCommand.SagaId);
            Bus.Send(doSomethingElseCommand);
        }
 public Foo(DoSomethingCommand doSomethingCommand)
 {
     _doSomethingCommand = doSomethingCommand;
 }
 public virtual void DoSomethingHandler(DoSomethingCommand command) {
     this.DoSomething(command.Sender as TestViewModel);
 }
예제 #11
0
 public void Handle(DoSomethingCommand command, CancellationToken cancellationToken)
 {
     base.Handle(command);
 }
예제 #12
0
 public async void DoSomething(DoSomethingCommand command)
 {
     // Method signature is not allowed.
     await Task.Delay(1);
 }
예제 #13
0
 public void DoSomething(DoSomethingCommand command)
 {
     base.Handle(command);
 }
예제 #14
0
 public ImageListItemViewModel()
 {
     DoSomethingCommand     = new DoSomethingCommand();
     DoSomethingElseCommand = new DoSomethingElseCommand();
 }
예제 #15
0
 public ViewModel()
 {
     DoSomethingCommand = ReactiveCommand.CreateFromTask(DoSomethingAsync);
     DoSomethingCommand.Subscribe(_ => { this.Message = "Finished"; });
 }
예제 #16
0
 public virtual void DoSomethingHandler(DoSomethingCommand command)
 {
     this.DoSomething(command.Sender as TestViewModel);
 }
예제 #17
0
 public Foo(DoSomethingCommand doSomethingCommand)
 {
     _doSomethingCommand = doSomethingCommand;
 }
 public virtual void ExecuteDoSomething(DoSomethingCommand command) {
     command.Sender = Test;
     Test.DoSomething.OnNext(command);
 }
예제 #19
0
 public virtual void ExecuteDoSomething(DoSomethingCommand command)
 {
     command.Sender = Test;
     Test.DoSomething.OnNext(command);
 }