-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced `CreateProduct` command and handler in `CreateProduct.cs`, replacing the removed `ProductCreated` command and its associated classes. Updated service registration in `Program.cs` to reflect this change. Modified `MessagingSample.csproj` to set `<IsPackable>false</IsPackable>`, indicating the project is not packable as a NuGet package.
- Loading branch information
Showing
4 changed files
with
32 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Infinity.Toolkit.Experimental; | ||
using Infinity.Toolkit.Experimental.Mediator; | ||
|
||
namespace MediatorSample; | ||
|
||
internal record CreateProduct(int Id, string Name) : ICommand; | ||
|
||
internal class CreateProductHandler : IMediatorHandler<CreateProduct> | ||
{ | ||
public Task<Result> HandleAsync(MediatorHandlerContext<CreateProduct> context, CancellationToken cancellationToken = default) | ||
{ | ||
Console.WriteLine("CreateProductHandler:HandleAsync"); | ||
Console.WriteLine($"Product created: {context.Request.Id} - {context.Request.Name}"); | ||
Console.WriteLine("CreateProductHandler:HandleAsync:Done"); | ||
return Task.FromResult(Result.Success()); | ||
} | ||
} | ||
|
||
internal class CreateProductDecorator(IMediatorHandler<CreateProduct> inner) : IMediatorHandler<CreateProduct> | ||
{ | ||
public async Task<Result> HandleAsync(MediatorHandlerContext<CreateProduct> context, CancellationToken cancellationToken = default) | ||
{ | ||
Console.WriteLine("CreateProductDecorator:HandleAsync"); | ||
var result = await inner.HandleAsync(context, cancellationToken); | ||
Console.WriteLine("CreateProductDecorator:HandleAsync:Done"); | ||
return result; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters