The request and the response can be any C# classes.
public class PresentProductsRequest
{
}
public class PresentProductsResponse
{
}
The use case must implement the IUseCase
interface.
internal class PresentProductsUseCase : IUseCase<PresentProductsRequest, PresentProductsResponse>
{
public Task<PresentProductsResponse> Execute(PresentProductsRequest request, CancellationToken cancellationToken)
{
// Return the list of products.
}
}
Note: The response class is optional, it may be missing if the use case has nothing to return.
RequestBus requestBus = new RequestBus();
requestBus.RegisterUseCase<PresentProductsUseCase>();
PresentProductsRequest request = new PresentProductsRequest();
PresentProductsResponse response = requestBus.Process<PresentProductsRequest, PresentProductsResponse>(request);