public CommandModule() { For<CreateTShirtV1>() .Handle((_, __) => { throw new NotSupportedException(); }); // 2. No longer support V1 var createTShirtV3Handler = For<CreateTShirtV3>() // 3. Here we keep a reference to the V3 handler... .Handle((commandMessage, ct) => Task.FromResult(0)); For<CreateTShirtV2>() .Handle((commandMessage, ct) => { var command = new CreateTShirtV3 { Name = commandMessage.Command.Name, Sizes = commandMessage.Command.Sizes, Colors = new []{ "Black" } }; var upconvertedCommand = new CommandMessage<CreateTShirtV3>( commandMessage.CommandId, command, commandMessage.Metadata); return createTShirtV3Handler(upconvertedCommand, ct); // 4. ... and invoke it here }); }
public CommandModule() { For <CreateTShirtV1>() .Handle((_, __) => { throw new NotSupportedException(); }); // 2. No longer support V1 var createTShirtV3Handler = For <CreateTShirtV3>() // 3. Here we keep a reference to the V3 handler... .Handle((commandMessage, ct) => Task.FromResult(0)); For <CreateTShirtV2>() .Handle((commandMessage, ct) => { var command = new CreateTShirtV3 { Name = commandMessage.Command.Name, Sizes = commandMessage.Command.Sizes, Colors = new [] { "Black" } }; var upconvertedCommand = new CommandMessage <CreateTShirtV3>( commandMessage.CommandId, command, commandMessage.Metadata); return(createTShirtV3Handler(upconvertedCommand, ct)); // 4. ... and invoke it here }); }