-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe1c487
commit bc31fd7
Showing
4 changed files
with
71 additions
and
2 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
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,50 @@ | ||
using Dummy; | ||
using Immediate.Handlers.Utility; | ||
|
||
[assembly: RenderMode(renderMode: RenderMode.Normal)] | ||
|
||
[assembly: Behaviors( | ||
typeof(LoggingBehavior<,>) | ||
)] | ||
|
||
namespace Dummy; | ||
|
||
public class GetUsersEndpoint(GetUsersQuery.Handler handler) | ||
{ | ||
public async Task<IEnumerable<User>> GetUsers() => | ||
handler.HandleAsync(new GetUsersQuery.Query()); | ||
} | ||
|
||
[Handler] | ||
public static class GetUsersQuery | ||
{ | ||
public record Query; | ||
|
||
private static Task<IEnumerable<User>> HandleAsync( | ||
Query _, | ||
UsersService usersService, | ||
CancellationToken token) | ||
{ | ||
return usersService.GetUsers(); | ||
} | ||
} | ||
|
||
public class LoggingBehavior<TRequest, TResponse>(ILogger<LoggingBehavior<TRequest, TResponse>> logger) | ||
: Behavior<TRequest, TResponse> | ||
{ | ||
public override async Task<TResponse> HandleAsync(TRequest request, CancellationToken cancellationToken) | ||
{ | ||
var response = await InnerHandler.HandleAsync(request, cancellationToken); | ||
|
||
return response; | ||
} | ||
} | ||
|
||
public class User { } | ||
public class UsersService | ||
{ | ||
public Task<IEnumerable<User>> GetUsers() => | ||
Task.FromResult(Enumerable.Empty<User>()); | ||
} | ||
|
||
public interface ILogger<T>; |
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