This file contains hidden or 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
| [Route("api/[controller]")] | |
| public class AccountsController : Controller | |
| { | |
| private readonly IMediator _mediator; | |
| public AccountsController(IMediator mediator) | |
| { | |
| _mediator = mediator; | |
| } |
This file contains hidden or 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
| public class Startup | |
| { | |
| // ... restante do arquivo | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| AddApplicationServices(services); | |
| services.AddMvc(); | |
| } |
This file contains hidden or 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
| public class CreateUser : IRequest<Response> | |
| { | |
| public string Name { get; } | |
| public string Email { get; } | |
| public string Password { get; } | |
| public string ConfirmPassword { get; } | |
| public CreateUser(string name, string email, string password, string confirmPassword) | |
| { | |
| Name = name; |
This file contains hidden or 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
| public class FailFastRequestBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> | |
| where TRequest : IRequest<TResponse> where TResponse : Response | |
| { | |
| private readonly IEnumerable<IValidator> _validators; | |
| public FailFastRequestBehavior(IEnumerable<IValidator<TRequest>> validators) | |
| { | |
| _validators = validators; | |
| } |
This file contains hidden or 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
| public class LoggingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> | |
| { | |
| public async Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next) | |
| { | |
| await Logger.InfoAsync($"Handling {typeof(TRequest).Name}"); | |
| var response = await next(); | |
| await Logger.InfoAsync($"Handled {typeof(TResponse).Name}"); | |
This file contains hidden or 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
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddMediatR(); | |
| } |
This file contains hidden or 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
| [Route("api/[controller]")] | |
| public class AccountsController : Controller | |
| { | |
| private readonly IMediator _mediator; | |
| public AccountsController(IMediator mediator) | |
| { | |
| _mediator = mediator; | |
| } |
This file contains hidden or 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
| public class Ping : IRequest<string> | |
| { | |
| } |
This file contains hidden or 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
| public class OneWay : IRequest | |
| { | |
| } |
This file contains hidden or 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
| public class CustomCompressionProvider : ICompressionProvider | |
| { | |
| public string EncodingName => "mycustomcompression"; | |
| public bool SupportsFlush => true; | |
| public Stream CreateStream(Stream outputStream) | |
| { | |
| return outputStream; | |
| } | |
| } |