CleanResult.WolverineFx
1.2.4
dotnet add package CleanResult.WolverineFx --version 1.2.4
NuGet\Install-Package CleanResult.WolverineFx -Version 1.2.4
<PackageReference Include="CleanResult.WolverineFx" Version="1.2.4" />
<PackageVersion Include="CleanResult.WolverineFx" Version="1.2.4" />
<PackageReference Include="CleanResult.WolverineFx" />
paket add CleanResult.WolverineFx --version 1.2.4
#r "nuget: CleanResult.WolverineFx, 1.2.4"
#:package CleanResult.WolverineFx@1.2.4
#addin nuget:?package=CleanResult.WolverineFx&version=1.2.4
#tool nuget:?package=CleanResult.WolverineFx&version=1.2.4
CleanResult.WolverineFx
CleanResult extension for WolverineFx.
This package provies custom handler continuation strategy for wolverineFx.
Usage
Registering the continuation strategy
host.UseWolverine(opts =>
{
opts.CodeGeneration.AddContinuationStrategy<CleanResultContinuationStrategy>();
});
Using the continuation strategy
If message handler contains Load
/LoadAsync
method with return type CleanResult
,
the continuation strategy will check is the value return from load method is success
or error.
If the value is error, this strategy will skip the Handle
method and
return error response to the caller.
If the value is success, it will continue to Handle
method and if the CleanResult
contains SuccessValue
it will be available in DI for Handle
method.
public record UpdateTodoCommand(Guid Id, string Title, string Description, bool IsCompleted);
public class UpdateTodoCommandHandler
{
public static async Task<Result<Todo>> LoadAsync(UpdateTodoCommand command, IQuerySession session)
{
var todo = await session.LoadAsync<Todo>(command.Id);
if (todo is null)
return Result.Error("Todos not found.", HttpStatusCode.NotFound);
return Result.Ok(todo);
}
public static async Task<Result<TodoUpdated>> Handle(UpdateTodoCommand command, Todo todo, IDocumentSession session)
{
command.Adapt(todo);
session.Update(todo);
await session.SaveChangesAsync();
return Result.Ok(todo.Adapt<TodoUpdated>());
}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- CleanResult (>= 1.2.4)
- WolverineFx (>= 4.5.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.